├── CLFS_For_LoongArch64.md ├── ChangeLog.md ├── Desktop.md ├── Qemu_For_LoongArch64-Simple.md ├── Qemu_For_LoongArch64.md ├── README.md ├── english ├── ChangeLog_en.md ├── Qemu_For_LoongArch64-Simple_en.md ├── Qemu_For_LoongArch64_en.md └── README_en.md ├── patches ├── 0001-Add-the-missing-LoongArch-definition-in-the-v8.gyp-f.patch ├── 0001-Fix-english-db-build-error.patch ├── 0001-Fix-loongarch64-double-float-define-to-loongarch64-l.patch ├── 0001-QT-5.15.8-add-loongarch64-support.patch ├── 0001-enable-cross-compilation.patch ├── 0001-ibus-1.5.28-change-for-cross-compiler.patch ├── 0001-librsvg-2.54.5-fix-loongarch64-support.patch ├── 0001-linux-raw-sys-add-loongarch64-support.patch ├── 0001-mozjs-91-add-loongarch64-supprot.patch ├── 0001-qt5-5.15-add-stdint-for-compiler-use-gcc-13.patch ├── 0001-rustc-1.69.0-add-loongarch-support.patch ├── 0001-rustc-1.69.0-vendor-nix-add-loongarch64-support.patch ├── 0001_xpcom_add_loongarch64_support.patch ├── cmake-3.22.3-add-loongarch64-to-checktypesize.patch ├── ctags-5.8-fix_form_fedora.patch ├── ctags-5.8-for-gcc_12.patch ├── firefox-100-add-loongarch.patch ├── firefox-100-for-clfs.patch ├── firefox-105-fix-for-gcc13.patch ├── firefox-105-fix-jit-for-loongarch64.patch ├── firefox-110-fix-rust.patch ├── gc-8.0.6-add-loongarch.patch ├── gpm-1.20.1-weak-wgetch.patch ├── gpm-1.20.7-consolidated-1.patch ├── kbd-2.4.0-backspace-1.patch ├── lua-5.4.4-shared_library-1.patch ├── nspr-4.32-add-loongarch64.patch ├── perl-5.36.0-loongarch64-config.sh ├── pyqt-5.15.6-cross_compiler.patch ├── pyqt-5.15.6-fix-sip.patch ├── qt-everywhere-src-5.15.2-add-loongarch-config.patch ├── sip-4.19.25-pyframe_getback.patch ├── sip-add-loongarch64.patch ├── stack-direction-add-loongarch.patch ├── userspace-rcu-0.13.1-add-loongarch64.patch ├── wireless_tools-29-fix_iwlist_scanning-1.patch ├── xf86-video-ati-19.1.0-upstream_fixes-1.patch └── xorg-server-21.1.3-fix-x11perf-segment-fault.patch └── 历史版本 ├── CLFS_For_LoongArch64-20210618.md ├── CLFS_For_LoongArch64-20210801.md ├── CLFS_For_LoongArch64-20210812.md ├── CLFS_For_LoongArch64-20210818.md ├── CLFS_For_LoongArch64-20210822.md ├── CLFS_For_LoongArch64-20210831.md ├── CLFS_For_LoongArch64-20210903.md ├── CLFS_For_LoongArch64-20210903_en.md └── CLFS_For_LoongArch64-20220108.md /ChangeLog.md: -------------------------------------------------------------------------------- 1 | ##### 20210831 2 | - 重新获取工具链代码,并重构整个系统 3 | - 去掉"-march=loongarch"制作参数,工具链默认探测架构进行设置。 4 | - 更新以下软件包: 5 | Binutils 6 | Diffutils 7 | GCC 8 | Glibc 9 | Grep 10 | Libcap 11 | Linux-Firmware 12 | M4 13 | OpenSSL 14 | ACPI-Update 15 | 16 | - 增加以下软件包和制作步骤: 17 | Boost 18 | Ctags 19 | Ethtool 20 | Fontconfig 21 | Freetype 22 | Fribidi 23 | Glibmm 24 | GnuTLS 25 | Gobject-Introspection 26 | Harfbuzz 27 | Jasper 28 | Lcms 29 | Libaio 30 | Libcap 31 | Libgudev 32 | Libgusb 33 | Libjpeg-Turbo 34 | Libmng 35 | Libnl 36 | Libpng 37 | LibRaw 38 | Libsigc++ 39 | Libtasn1 40 | Libusb 41 | Libunistring 42 | LVM2 43 | Mdadm 44 | Nettle 45 | OpenJPEG 46 | P11-Kit 47 | TIFF 48 | Usbutils 49 | Vala 50 | Wireless-Tools 51 | Wpa_Supplicant 52 | 53 | - 增加系统第一次使用时需要执行的命令步骤 54 | 55 | ##### 20210822 56 | - 增加CMake软件包的制作步骤 57 | - 增加CURL软件包的制作步骤 58 | - 增加Dosfstools软件包的制作步骤 59 | - 增加Doxygen软件包的制作步骤 60 | - 增加Git软件包的制作步骤 61 | - 增加Glib软件包的制作步骤 62 | - 增加ICU4C软件包的制作步骤 63 | - 增加Inih软件包的制作步骤 64 | - 增加Libxml2软件包的制作步骤 65 | - 增加Libxslt软件包的制作步骤 66 | - 增加Meson软件包的制作步骤 67 | - 增加NSPR软件包的制作步骤 68 | - 增加NSS软件包的制作步骤 69 | - 增加PCRE软件包的制作步骤 70 | - 增加Python-Pip软件包的制作步骤 71 | - 增加Python-Setuptools软件包的制作步骤 72 | - 增加Sqlite3软件包的制作步骤 73 | - 增加Sudo软件包的制作步骤 74 | - 增加Xfsprogs软件包的制作步骤 75 | - 增加UnRAR软件包的制作步骤 76 | - 增加UnZip软件包的制作步骤 77 | - 增加Zip软件包的制作步骤 78 | 79 | ##### 20210818 80 | - 增加Python软件包的制作步骤 81 | - 增加Perl软件包的制作步骤 82 | - 增加XML-Parser软件包的制作步骤 83 | - 增加GPM软件包的制作步骤 84 | - 增加证书文件的安装步骤 85 | - 增加Libevent软件包的制作步骤 86 | - 增加Links软件包的制作步骤 87 | 88 | ##### 20210812 89 | - 采用20210801之后更新的Binutils和GCC作为工具链,该工具链更新了部分LA指令集 90 | - 更新GCC的制作步骤,去掉了--with-arch和--with-tls选项 91 | - 更新支持LoongArch的Linux内核源代码制作步骤,适合日期2021-08-21之后更新的5.14-rc5版本,支持更新后的工具链编译 92 | - 更新GCC和Glibc生成的ld.so.1改为ld-linux-loongarch64.so.1的补丁 93 | - 更新Grub软件包的制作步骤,支持更新后的工具链编译 94 | - 更新Linux-Firmware软件包 95 | - 增加ACPI-Update的制作步骤 96 | - 增加DHCPCD软件包的制作步骤 97 | - 增加Inetutils软件包的制作步骤 98 | - 增加OpenSSH软件包的制作步骤 99 | - 增加PCIUtils软件包的制作步骤 100 | - 增加WGet软件包 的制作步骤 101 | 102 | ##### 20210801 103 | - 采用开源的Binutils、GCC、Glibc和Linux内核制作CLFS系统。 104 | -------------------------------------------------------------------------------- /Desktop.md: -------------------------------------------------------------------------------- 1 | #
手把手教你构建基于LoongArch64架构的Linux系统(桌面应用篇)
2 | 3 |
(Desktop Application For LoongArch64)
4 | 5 |
作者:孙海勇
6 | 7 | ## 0 制作说明 8 | 9 | 本文是CLFS for LoongArch文档的扩展内容,主要针对桌面应用相关的软件包制作。 10 | 11 | ## 1 制作环境的准备 12 | 13 | 本文制作步骤基于CLFS for LoongArch文档制作的基础系统来进行,因此默认认为当前具备了交叉编译的基础系统的环境。 14 | 15 | #### 切换到制作用户 16 | 17 |   使用命令切换到新创建的用户: 18 | 19 | ```sh 20 | su - lauser 21 | ``` 22 | 23 |   使用“su”命令进行切换时加上“-”参数可以防止切换前的用户环境变量带到新用户环境中。 24 | 25 | 26 | ## 2 设置环境变量 27 | 28 | ```sh 29 | export LDFLAGS="-Wl,-rpath-link=${SYSDIR}/sysroot/usr/lib64" 30 | export PKG_CONFIG_SYSROOT_DIR=${SYSDIR}/sysroot 31 | export PKG_CONFIG_PATH="${SYSDIR}/sysroot/usr/lib64/pkgconfig:${SYSDIR}/sysroot/usr/share/pkgconfig" 32 | export COMMON_CONFIG="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 \ 33 | --build=${CROSS_HOST} --host=${CROSS_TARGET}" 34 | export JOBS="-j8" 35 | ``` 36 | 37 | ## 3 软件包的制作 38 | 39 | #### VLC 40 | https://download.videolan.org/vlc/3.0.17.4/vlc-3.0.17.4.tar.xz 41 | 42 | ```sh 43 | tar xvf ${DOWNLOADDIR}/vlc-3.0.17.4.tar.xz -C ${BUILDDIR} 44 | pushd ${BUILDDIR}/vlc-3.0.17.4 45 | patch -Np1 -i ${DOWNLOADDIR}/0001-VLC-fix-for-gcc13.patch 46 | ./configure $COMMON_CONFIG --disable-chromecast 47 | make -C compat ${JOBS} 48 | make -C src ${JOBS} 49 | make -C src DESTDIR=${SYSDIR}/sysroot install 50 | make ${JOBS} 51 | make DESTDIR=${SYSDIR}/sysroot install 52 | popd 53 | ``` 54 | 55 | #### SimpleScreenRecorder 56 | https://github.com/MaartenBaert/ssr.git 57 | 58 | ```sh 59 | git clone https://github.com/MaartenBaert/ssr.git --depth 1 60 | pushd ssr 61 | patch -Np1 -i ${DOWNLOADDIR}/ssr-add-loongarch64.patch 62 | mkdir cross-build 63 | pushd cross-build 64 | CC="${CROSS_TARGET}-gcc" CXX="${CROSS_TARGET}-g++" \ 65 | cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release \ 66 | -DPKG_CONFIG_EXECUTABLE=${SYSDIR}/cross-tools/bin/${CROSS_TARGET}-pkg-config \ 67 | -DCMAKE_SYSROOT=${SYSDIR}/sysroot \ 68 | -DCMAKE_FIND_ROOT_PATH=${SYSDIR}/sysroot/usr \ 69 | -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib64 \ 70 | -DWITH_QT5=TRUE \ 71 | .. 72 | make ${JOBS} 73 | make DESTDIR=${SYSDIR}/sysroot install 74 | popd 75 | popd 76 | ``` 77 | 78 | #### LibreOffice 79 | 80 | 获取软件代码。 81 | 82 | ```sh 83 | git clone https://git.libreoffice.org/core --depth 1 84 | pushd core 85 | git submodule init 86 | git submodule update --depth 1 87 | popd 88 | mv core libreoffice-7.5-git 89 | tar -czf ${DOWNLOADDIR}/libreoffice-7.5-git.tar.gz libreoffice-7.5-git 90 | ``` 91 | 92 | 编译和安装。 93 | 94 | ``` 95 | tar xvf ${DOWNLOADDIR}/libreoffice-7.5-git.tar.gz -C ${BUILDDIR} 96 | pushd ${BUILDDIR}/libreoffice-7.5-git 97 | cp ${SYSDIR}/cross-tools/share/automake-1.16/config.* ./ 98 | aclocal 99 | patch -Np1 -i ${DOWNLOADDIR}/libreoffice-7.5-for-clfs.patch 100 | patch -Np1 -i ${DOWNLOADDIR}/libreoffice-7.5-libgpg-error-add-loongarch64.patch 101 | patch -Np1 -i ${DOWNLOADDIR}/libreoffice-7.5-postgresql-disable_spinlock.patch 102 | PKG_CONFIG_FOR_BUILD=/bin/pkg-config \ 103 | perl ./autogen.sh CC=${CROSS_TARGET}-gcc CXX=${CROSS_TARGET}-g++ \ 104 | --build=${CROSS_HOST} --host=${CROSS_TARGET} \ 105 | --prefix=/opt/libreoffice \ 106 | --with-lang="zh-CN" --with-vendor=Sunhaiyong \ 107 | --with-help --with-myspell-dicts \ 108 | --without-junit --without-system-dicts --disable-dconf --disable-odk \ 109 | --enable-release-build=yes --without-java \ 110 | --with-system-boost --with-system-curl --with-system-epoxy \ 111 | --with-system-expat --with-system-graphite --with-system-harfbuzz \ 112 | --with-system-icu --with-system-jpeg --with-system-lcms2 \ 113 | --with-system-libatomic_ops --with-system-libpng --with-system-libxml \ 114 | --with-system-nss --with-system-openssl \ 115 | --with-system-zlib --with-system-openjpeg \ 116 | LIBS="-lstdc++" \ 117 | --with-boost-libdir=${SYSDIR}/sysroot/usr/lib64 \ 118 | --disable-coinmp --enable-python=no 119 | ZIC=/usr/sbin/zic make build ${JOBS} 120 | make DESTDIR=${PWD}/dest distro-pack-install 121 | cp -a ${PWD}/dest/opt/libreoffice ${SYSDIR}/sysroot/opt/ 122 | mkdir -pv ${SYSDIR}/sysroot/usr/share/bash-completion/completions/ 123 | cp -a ${PWD}/dest/usr/share/bash-completion/completions/* ${SYSDIR}/sysroot/usr/share/bash-completion/completions/ 124 | cp -a ${PWD}/dest/opt/libreoffice/share/applications/*.desktop \ 125 | ${SYSDIR}/sysroot/usr/share/applications/ 126 | mkdir -pv ${SYSDIR}/sysroot/usr/share/xdg/ 127 | cp -a ${PWD}/dest/opt/libreoffice/lib/libreoffice/share/xdg/*.desktop \ 128 | ${SYSDIR}/sysroot/usr/share/xdg/ 129 | popd 130 | ``` 131 | 132 | 133 | #### Thunderbird 100 134 | https://archive.mozilla.org/pub/thunderbird/releases/100.0b4/source/thunderbird-100.0b4.source.tar.xz 135 | 136 | ```sh 137 | tar xvf ${DOWNLOADDIR}/thunderbird-100.0b4.source.tar.xz -C ${BUILDDIR} 138 | pushd ${BUILDDIR}/thunderbird-100.0 139 | mkdir -pv mozbuild/l10n-central 140 | pushd mozbuild/l10n-central 141 | unzip ${DOWNLOADDIR}/firefox-100-l10.zip 142 | mv zh-CN* zh-CN 143 | popd 144 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-add-loongarch.patch 145 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-add-rust-libc.patch 146 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-xpcom-add-loongarch.patch 147 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-for-clfs.patch 148 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-workround.patch 149 | patch -Np1 -i ${DOWNLOADDIR}/firefox-100-fix-for-gcc13.patch 150 | cat > comm/third_party/botan/src/build-data/arch/loongarch64.txt << "EOF" 151 | family loongarch 152 | endian little 153 | wordsize 64 154 | EOF 155 | 156 | cat > mozconfig << "EOF" 157 | ac_add_options --disable-necko-wifi 158 | ac_add_options --with-system-libevent 159 | ac_add_options --with-system-libvpx 160 | ac_add_options --with-system-nspr 161 | ac_add_options --with-system-nss 162 | ac_add_options --with-system-icu 163 | ac_add_options --prefix=/usr 164 | ac_add_options --libdir=/usr/lib64 165 | ac_add_options --target=loongarch64-unknown-linux-gnu 166 | ac_add_options --enable-application=comm/mail 167 | ac_add_options --disable-jit 168 | ac_add_options --disable-crashreporter 169 | ac_add_options --disable-updater 170 | ac_add_options --disable-debug 171 | ac_add_options --disable-debug-symbols 172 | ac_add_options --disable-tests 173 | ac_add_options --enable-optimize=-O2 174 | ac_add_options --enable-official-branding 175 | ac_add_options --enable-system-ffi 176 | ac_add_options --enable-system-pixman 177 | ac_add_options --with-system-jpeg 178 | ac_add_options --with-system-png 179 | ac_add_options --with-system-zlib 180 | ac_add_options --without-wasm-sandboxed-libraries 181 | ac_add_options --with-system-webp 182 | ac_add_options --disable-strip 183 | ac_add_options --disable-jemalloc 184 | ac_add_options --disable-install-strip 185 | ac_add_options --enable-fmp4 186 | ac_add_options --with-sysroot=${SYSDIR}/sysroot 187 | 188 | unset MOZ_TELEMETRY_REPORTING 189 | mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/thunderbird-build-dir 190 | EOF 191 | CC=${CROSS_TARGET}-gcc CXX=${CROSS_TARGET}-g++ \ 192 | CXXFLAGS="-fpermissive" \ 193 | MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system MOZBUILD_STATE_PATH=${PWD}/mozbuild \ 194 | ./mach configure 195 | CC=${CROSS_TARGET}-gcc CXX=${CROSS_TARGET}-g++ \ 196 | CXXFLAGS="-fpermissive" \ 197 | MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system MOZBUILD_STATE_PATH=${PWD}/mozbuild \ 198 | ./mach build ${JOBS} 199 | CC=${CROSS_TARGET}-gcc CXX=${CROSS_TARGET}-g++ \ 200 | CXXFLAGS="-fpermissive" \ 201 | MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system MOZBUILD_STATE_PATH=${PWD}/mozbuild \ 202 | ./mach package 203 | CC=${CROSS_TARGET}-gcc CXX=${CROSS_TARGET}-g++ \ 204 | CXXFLAGS="-fpermissive" \ 205 | MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system MOZBUILD_STATE_PATH=${PWD}/mozbuild \ 206 | ./mach build installers-zh-CN 207 | tar xvf thunderbird-build-dir/dist/thunderbird-100.0.zh-CN.linux-loongarch64.tar.bz2 \ 208 | -C ${SYSDIR}/sysroot/usr/lib64/ 209 | ln -sfv /usr/lib64/thunderbird/thunderbird ${SYSDIR}/sysroot/usr/bin/thunderbird 210 | popd 211 | cat > ${SYSDIR}/sysroot/usr/share/applications/thunderbird.desktop << "EOF" 212 | [Desktop Entry] 213 | Encoding=UTF-8 214 | Name=Thunderbird Mail 215 | Name[zh_CN]=邮件客户端 216 | Comment=Send and receive mail 217 | Comment[zh_CN]=邮件客户端 218 | GenericName=邮件客户端 219 | Exec=thunderbird %u 220 | Terminal=false 221 | Type=Application 222 | Icon=thunderbird 223 | Categories=Network;Email; 224 | MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;x-scheme-handler/mailto; 225 | StartupNotify=true 226 | EOF 227 | ln -sfv ${SYSDIR}/sysroot/usr/lib/thunderbird/chrome/icons/default/default256.png \ 228 | ${SYSDIR}/sysroot/usr/share/pixmaps/thunderbird.png 229 | ``` 230 | 231 | ## 4 处理目标系统 232 | 233 | ### 清理符号(symbol)信息 234 |   目前安装到目标系统中的二进制文件大多带有各种符号信息,这些信息不影响执行,但是占用了大量的存储空间,如果没有调试相关的需求,可以将这些信息清理掉以减少存储空间。 235 | 236 |   清理符号信息可以使用strip命令,但strip必须能够处理目标平台二进制,所以我们可以使用交叉编译工具链中的strip命令来操作,操作步骤如下: 237 | 238 | ```sh 239 | pushd ${SYSDIR}/sysroot 240 | find usr/lib{,64} -type f -name \*.a -exec ${CROSS_TARGET}-strip --strip-debug {} ';' 241 | find usr/lib{,64} -type f -name \*.so* -exec ${CROSS_TARGET}-strip --strip-unneeded {} ';' 242 | find usr/{bin,sbin,libexec} -type f -exec ${CROSS_TARGET}-strip --strip-all {} ';' 243 | find opt -type f -exec ${CROSS_TARGET}-strip --strip-unneeded {} ';' 244 | popd 245 | ``` 246 | 247 |   这里我们发现strip使用的参数有多种,这里简单的说明一下: 248 |   * `--strip-debug`,仅去掉调试相关的符号信息,该参数适合用于静态库文件,对于链接过程需要的信息是不会去掉的。 249 |   * `--strip-unneeded`,删除所有与重定位无关的所有符号信息,该参数不能用于静态库文件,否则会导致静态链接时无法使用处理过的静态库。 250 |   * `--strip-all`,该参数代表所有能去掉的符号信息都尽量去掉,该参数不建议用于库文件,特别是静态库文件。 251 | 252 | ### 清除.la文件 253 | ```sh 254 | find ${SYSDIR}/sysroot/usr/lib64/ -type f -name "*.la" -exec rm '{}' ';' 255 | ``` 256 | 257 | ### 打包系统 258 |   制作完成后就可以退出制作用户环境了,使用命令: 259 | 260 | ```sh 261 | exit 262 | ``` 263 | 264 | 265 | ### 打包系统 266 | 267 |   接着可以使用root权限对目标系统进行打包,打包步骤如下: 268 | 269 | ```sh 270 | pushd ${SYSDIR}/sysroot 271 | sudo tar --xattrs-include='*' --owner=root --group=root -cjpf \ 272 | ${SYSDIR}/loongarch64-clfs-system-6.1-DesktopApp.tar.bz2 * 273 | popd 274 | ``` 275 | 276 | ## 附录 277 | 278 | ### 参考资料 279 | 《用“芯”探索 教你构建龙芯平台的Linux系统》 孙海勇 著 280 | 281 | LFS: https://www.linuxfromscratch.org/lfs/ 282 | 283 | BLFS: https://www.linuxfromscratch.org/blfs/ 284 | -------------------------------------------------------------------------------- /Qemu_For_LoongArch64-Simple.md: -------------------------------------------------------------------------------- 1 | #
使用QEMU运行基于LoongArch64架构的Linux系统(简化版本)
2 | 3 |
(Qemu For LoongArch64 Simple)
4 | 5 |
作者:孙海勇
6 | 7 | ## 1 前言 8 |   本文是 https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/Qemu_For_LoongArch64.md 文档的简化版本。 9 | 10 |   本文的目的是通过简单的操作使用QEMU运行一个基于LoongArch64制作的Linux系统。 11 | 12 | ## 2 环境准备 13 | ### 准备Linux系统 14 |   请准备一个通用Linux的环境,比如Fedora、Debian等。 15 | 16 | ### 下载QEMU 17 |   在Linux环境中下载可以支持LoongArch架构的QEMU: 18 | 19 |   机器是X86系统,下载地址: 20 | 21 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-x86_64-to-loongarch64 22 | 23 |   如果你刚巧手上有一个龙芯3A 4000的机器,刚巧也有一个,下载地址: 24 | 25 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-mips64el-to-loongarch64 26 | 27 | 请将下载的文件更名为qemu-loongarch64,并存放到/bin目录中,如X86的文件使用命令: 28 | 29 | ```sh 30 | cp qemu-x86_64-to-loongarch64 /bin/qemu-loongarch64 31 | ``` 32 | 33 | #### 下载LoongArch的Linux系统 34 |   在GitHub上有已经制作好的LoongArch Linux系统,使用以下地址步骤进行下载: 35 | 36 | ```sh 37 | cd /tmp 38 | wget -c https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/loongarch64-clfs-system-20210903.tar.bz2 39 | ``` 40 | 41 |   以上下载的系统是一个完全使用已开放的源代码构建的基于LoongArch指令集架构的Linux系统。 42 | 43 | 44 | #### 解压缩LoongArch的Linux系统 45 |   请使用root权限的用户完成以下解压缩的步骤: 46 | 47 | ```sh 48 | cd /opt 49 | mkdir clfs-os 50 | cd clfs-os 51 | tar xvpf /tmp/loongarch64-clfs-system-20210903.tar.bz2 52 | ``` 53 |   经过一段时间的解压后,我们就在/opt/clfs-os目录中拥有了一个基于LoongArch指令集制作的系统。 54 | 55 | ## 3 使用QEMU 56 | 57 |   接下来就是在Binfmt注册LoongArch可执行文件的信息了,使用如下命令: 58 | 59 | ```sh 60 | echo ":qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/bin/qemu-loongarch64:" > /proc/sys/fs/binfmt_misc/register 61 | ``` 62 | 63 |   以上命令注册了LoongArch可执行文件“头信息”,并指定符合条件的文件会使用"/bin/qemu-loongarch64"命令来执行,所以这个"/bin/qemu-loongarch64"命令必须真实有效。 64 | 65 |   想了解什么是Binfmt,可自行上网搜索,或者看一下前言中所提及文档的简单说明。 66 | 67 | #### Chroot到LoongArch系统 68 |   要想方便的通过QEMU的Linux-User模式chroot到LoongArch的系统中,Binfmt功能的注册是必不可少的,当完成注册后还需要如下的一次性步骤: 69 | 70 | ```sh 71 | cp /bin/qemu-loongarch64 /opt/clfs-os/bin/ 72 | ``` 73 | 74 |   我们将qemu-loongarch64这个命令文件复制到需要chroot的系统中,这个步骤非常关键,并且要保证qemu-loongarch64在这个chroot的系统中存放的相对位置与当前系统中该命令的目录位置相同,即放在bin目录下。 75 | 76 |   接下来,我们就是见证胜利的时候,使用root权限的用户或者sudo命令进行chroot: 77 | 78 | ```sh 79 | chroot /opt/clfs-os 80 | ``` 81 |   这个时候我们会看到熟悉的Bash提示符: 82 | 83 |   bash-5.1# 84 | 85 |   尝试的输入一些命令,比如ls、vi,你会发现可以完全直接就运行起来了。 86 | 87 |   再输入: 88 | 89 | ```sh 90 | uname -m 91 | ``` 92 |   会返回: 93 | 94 |   loongarch 95 | 96 |   代表当前环境正模拟的LoongArch的架构。 97 | 98 |   接下来可以参考:https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/Qemu_For_LoongArch64.md 文档中的使用部分。 99 | 100 | ## 结束 101 | 102 |   感谢大家支持,欢迎提出宝贵的意见。 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /Qemu_For_LoongArch64.md: -------------------------------------------------------------------------------- 1 | #
使用QEMU运行基于LoongArch64架构的Linux系统
2 | 3 |
(Qemu For LoongArch64)
4 | 5 |
作者:孙海勇
6 | 7 | ## 1 前言 8 |   龙芯中科于2021年推出了全新指令集架构LoongArch,其中64位指令集称为LoongArch64。 9 |   基于LoongArch64指令集的操作系统需要运行在使用龙芯3A5000 CPU的机器上,在没有这样的机器的情况下如果想简单的体验就需要使用到QEMU这个模拟器。 10 |   本文的目标是通过一步一步的制作使用QEMU运行一个基于LoongArch64制作的Linux系统。 11 | 12 |   **文末有已编译好不同架构的QEMU文件可供下载,简化使用过程。** 13 | 14 |   本文涉及一些编译软件相关的操作,如果你想简单点来使用,可以参考简化版的文档: 15 |   https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/Qemu_For_LoongArch64-Simple.md 16 | 17 | ## 2 编译QEMU 18 | 19 |   本文将采用编译QEMU源代码的方式来创建可执行的QEMU,因当前大多数系统中的QEMU并未支持LoongArch64指令,所以接下来先从下载和编译QEMU开始说起。 20 | 21 | ### 准备编译环境 22 |   QEMU支持从不同的指令架构机器上模拟目标指令架构的环境,因此用的机器只要是能运行QEMU就可以了,当然这个用来运行QEMU的机器我们建议安装一个“正常”的Linux系统,因为后续还需要进行编译,所以必须能提供编译QEMU的开发环境。 23 | 24 |   因在不同架构的机器上制作QEMU并运行LoongArch64的Linux系统与架构本身并没有太大关系,主要差异仅在具体的Linux系统准备编译环境的步骤上会因为Linux所使用的包管理工具不同而有所不同,但在使用QEMU上几乎没有差异,所以接下来我们将以一个使用Fedora Linux发行版系统的环境来讲解。 25 | 26 |   如果你使用的是X86的机器,那么可以选择的系统版本非常多,而如果你用的是非X86架构的机器那么就要确定可使用的版本,接下来我们会以龙芯3A4000的机器上可以运行的Fedora28为例进行制作和使用的讲解,当然这些步骤也同样适合例如同样在3A4000上的Fedora 32这样更新的版本,或者在X86机器上的Fedora 34或者其他Linux系统上。 27 | 28 | #### 创建一个普通用户 29 |   不建议使用root用户来编译制作软件包,所以我们在一开始创建一个普通用户,比如“loongson”,如果系统中已经有了这个用户可以创建其他名字的用户或者跳过这个步骤。 30 | 31 |   创建命令如下: 32 | 33 | ```sh 34 | useradd -m loongson 35 | ``` 36 | 37 |   参数“-m”的用处是给这个新用户创建家目录,接下来我们会需要用到用户的家目录。 38 | 39 |   注意:创建用户的工作必须由具有root权限的用户来进行。 40 | 41 | #### 切换用户 42 |   创建好普通用户后,就可以切换到该用户下,使用如下命令: 43 | 44 | ```sh 45 | su loongson 46 | ``` 47 | 48 |   通过root用户切换到普通用户可以避免输入密码。 49 | 50 |   默认情况下切换用户后会自动进入该用户的家目录,之后的工作将在家目录中进行。 51 | 52 | ### 下载QEMU的源代码 53 | 54 |   QEMU中支持LoongArch64的代码目前还没有进入到QEMU的上游源代码仓库中,因此,我们需要下载一个有LoongArch64指令支持的QEMU源代码。 55 | 56 |   使用以下命令下载QEMU代码: 57 | 58 | ```sh 59 | git clone https://github.com/loongson/qemu.git -b tcg-dev 60 | ``` 61 | 62 | 经过一段时间的下载过程后我们就拥有了支持LoongArch64指令集的QEMU源代码。 63 | 64 | 65 | ### QEMU的支持模式 66 |   接下来就是最为关键的编译过程。 67 | 68 |   进入QEMU的源代码目录: 69 | 70 | ```sh 71 | cd ~/qemu 72 | ``` 73 |   注意:这里假定源代码是下载到当前用户的家目录中。 74 | 75 |   接下来,如果代码有需要打补丁或者修正问题的,可以在这个时候进行,例如下面修复一个在配置阶段可能出现的问题: 76 | 77 | ```sh 78 | sed -i '/compile_prog/s@"\$glib_cflags"@"\$glib_cflags -Werror"@g' configure 79 | ``` 80 | 81 | ```sh 82 | sed -i 's@"loongarch"@"loongarch64"@g' linux-user/loongarch64/target_syscall.h 83 | ``` 84 | 85 |   QEMU的编译参数非常的多,可以通过以下命令查看: 86 | 87 | ```sh 88 | ./configure --help 89 | ``` 90 | 91 |   这里我们关心的参数主要是“--target-list”,通过查看该参数支持的内容会发现,QEMU主要有两种使用方式,分别是:softmmu和linux-user,前者是系统仿真,而后者是linux用户模式仿真,简单的理解就是前面模拟了一台主机,后者模拟了Linux内核环境可以直接运行linux命令。 92 | 93 |   目前开放出来的支持LoongArch架构的QEMU源代码仅支持Linux-User模式,因此接下来按照该模式进行编译和使用。 94 | 95 | ### 安装编译依赖环境 96 |   在编译前需要安装一些系统软件开发包,这些软件包是编译QEMU时所需要的,通常在./configure配置阶段会给出目前系统中缺少的软件包名称,如果有确实就及时安装上,比如需要glib2的开发包,可以使用如下命令: 97 | 98 | ```sh 99 | dnf install glib2-devel 100 | ``` 101 |   除了安装必要的软件包的开发文件外,针对Linux-User模式还会用到一些静态库,因此也一并安装到系统中,例如: 102 | 103 | ```sh 104 | dnf install glib2-static pcre-static zlib-static 105 | ``` 106 | 107 |   注意,此时需要使用root权限的用户进行安装,或者给当前用户增加sudo执行的权限然后通过sudo命令进行安装。 108 | 109 | ### Linux-User模式 110 | 111 | #### 配置步骤 112 |   使用如下步骤先进行配置: 113 | 114 | ```sh 115 | ./configure --prefix=/usr --target-list=loongarch64-linux-user \ 116 | --disable-werror --static --disable-docs 117 | ``` 118 |   配置参数解释: 119 |   ```--prefix=/usr```:设置安装的基础目录。 120 |   ```--target-list=loongarch64-linux-user```:此配置参数是关键项,这里指定了loongarch64-linux-user,“loongarch64”代表支持LoongArch64架构,“linux-user”代表是Linux-User模式。 121 |   ```--disable-werror```:防止语法警告变成错误,这可能导致高版本的gcc编译QEMU时出现错误。 122 |   ```--static```:这个配置参数也时关键项,用于指定编译出来的二进制命令文件是静态链接的,这就需要系统中安装编译QEMU所需链接库文件的静态库。 123 |   ```--disble-docs```:该参数不是必须的,该参数用来取消文档文件的制作步骤,这样可以减少一些编译时间。 124 | 125 |   在配置阶段,需要保持联网状态,因配置过程中会需要从网络上下载一些文件,这个过程是一次性的,也就是第一次配置阶段会进行,只要软件源码目录没有被删除,后续重新配置时不再需要下载。 126 | 127 | #### 编译步骤 128 |   接下来进行编译,编译非常简单,使用make命令即可,如下: 129 | 130 | ```sh 131 | make 132 | ``` 133 | 134 |   当然,你要想加速编译,可以增加“-jN”参数,N需要替换成确定的数字,可以使用你当前"CPU核数*2+1"计算出的数字。 135 |   如果顺利经过一段时间(视机器性能)后即可完成编译。 136 | 137 | #### 安装步骤 138 |   编译完成后进行安装,这里不必使用常见的make install命令进行安装,因为当前我们只需要一个可执行文件即可,该文件存放在build目录中,切换到root用户权限下并使用如下命令安装: 139 | 140 | ```sh 141 | strip --strip-all build/qemu-loongarch64 142 | cp -a build/qemu-loongarch64 /bin/ 143 | ``` 144 |   strip命令可以用来剥离可执行文件中不需要的调试信息,可以极大的减少文件大小。 145 | 146 |   qemu-loongarch64命令被复制到/bin目录之后,就完成了安装。 147 | 148 | ## 3 使用QEMU 149 | 150 | ### Linux-User模式的使用 151 | 152 | #### 下载LoongArch的Linux系统 153 |   在GitHub上有已经制作好的LoongArch Linux系统,使用以下地址步骤进行下载: 154 | 155 | ```sh 156 | cd /tmp 157 | wget -c https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/loongarch64-clfs-system-20210903.tar.bz2 158 | ``` 159 | 160 |   以上下载的系统是一个完全使用已开放的源代码构建的基于LoongArch指令集架构的Linux系统。 161 | 162 | 163 | #### 解压缩Linux系统 164 |   请使用root权限的用户完成以下解压缩的步骤: 165 | 166 | ```sh 167 | cd /opt 168 | mkdir clfs-os 169 | cd clfs-os 170 | tar xvpf /tmp/loongarch64-clfs-system-20210903.tar.bz2 171 | ``` 172 |   经过一段时间的解压后,我们就在/opt/clfs-os目录中拥有了一个基于LoongArch指令集制作的系统。 173 | 174 | #### 测试QEMU的Linux-User模式 175 |   已经安装好QEMU和Linux系统后,就可以开始验证QEMU的Linux-User模式工作是否正常了,使用如下命令: 176 | 177 | ```sh 178 | /bin/qemu-loongarch64 -L /opt/clfs-os /opt/clfs-os/bin/ls / 179 | ``` 180 | 181 |   如果命令能正常执行并列出了当前系统根目录的内容,那么就代表QEMU的Linux-User模式已经能使用了。 182 | 183 | #### 注册Binfmt信息 184 |   当我们在测试Linux-User模式使用时会发现,为了执行一个命令,需要通过指定相关参数才行,这使得当我们想尝试chroot到这个系统中时,会因为这些额外的参数指定而导致很多不方便处理的问题,能不能像执行当前系统中的命令一样使用呢? 185 | 186 |   答案当然是可以,方案就是使用Binfmt方式执行。 187 | 188 |   Binfmt简单来说就是在内核中注册一个可执行文件的“头信息”,当执行的可执行文件符合注册的“头信息”时就会调用注册时指定的命令执行文件。 189 | 190 |   从上面的说明可以看出,Binfmt需要内核支持才可以使用,所以先确认以下当前的系统是否支持,使用命令: 191 | 192 | ```sh 193 | ls /proc/sys/fs/binfmt_misc/ 194 | ``` 195 |   如果显示该目录下有以下文件: 196 |   ```register status``` 197 |   代表Binfmt功能是打开的,再看以下status文件的内容: 198 | 199 | ```sh 200 | cat /proc/sys/fs/binfmt_misc/status 201 | ``` 202 | 203 |   如果显示为```enable```,则代表Binfmt功能目前内核支持且可用。 204 | 205 |   接下来就是注册LoongArch可执行文件的信息了,使用如下命令: 206 | 207 | ```sh 208 | echo ":qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/bin/qemu-loongarch64:" > /proc/sys/fs/binfmt_misc/register 209 | ``` 210 | 211 |   以上命令注册了LoongArch可执行文件“头信息”,并指定符合条件的文件会使用"/bin/qemu-loongarch64"命令来执行,所以这个"/bin/qemu-loongarch64"命令必须真实有效。 212 | 213 | #### Chroot到LoongArch系统 214 |   要想方便的通过QEMU的Linux-User模式chroot到LoongArch的系统中,Binfmt功能的注册是必不可少的,当完成注册后还需要如下的一次性步骤: 215 | 216 | ```sh 217 | cp /bin/qemu-loongarch64 /opt/clfs-os/bin/ 218 | ``` 219 | 220 |   我们将qemu-loongarch64这个命令文件复制到需要chroot的系统中,这个步骤非常关键,并且要保证qemu-loongarch64在这个chroot的系统中存放的相对位置与当前系统中该命令的目录位置相同,也就是保证与Binfmt中注册的路径相同,只有这样才能在chroot到新系统后Binfmt功能依旧能够找到正确的模拟器命令。 221 | 222 |   接下来,我们就是见证胜利的时候,使用root权限的用户或者sudo命令进行chroot: 223 | 224 | ```sh 225 | chroot /opt/clfs-os 226 | ``` 227 |   这个时候我们会看到熟悉的Bash提示符: 228 | 229 |   bash-5.1# 230 | 231 |   尝试的输入一些命令,比如ls、vi,你会发现可以完全直接就运行起来了。 232 | 233 |   再输入: 234 | 235 | ```sh 236 | uname -m 237 | ``` 238 |   会返回: 239 | 240 |   loongarch64 241 | 242 |   代表当前环境正模拟的LoongArch的架构。 243 | 244 | 245 | #### 图形程序的执行 246 |   在我们提供的LoongArch系统中,如果是在文本中断使用的命令,那么可以很容易的执行和操作,就跟本地架构的程序一样,然而要想执行一些图形环境下的程序会怎么样呢? 247 | 248 |   接下来我们以尝试运行一个图形系统下的终端程序为例来进行介绍。 249 | 250 | ##### 挂载必要的文件系统 251 |   对于一个chroot的系统来说,缺少必要的文件系统会影响部分程序的运行,可以在chroot后挂载几个必要的文件系统,步骤如下: 252 | 253 | ```sh 254 | mount -t proc proc /proc 255 | mount -t sysfs sys /sys 256 | mount -t devtmpfs dev /dev 257 | mount -t devpts devpts /dev/pts 258 | ``` 259 | 260 | ##### 创建普通用户 261 |   系统中有些程序对用户有一定的要求,比如不能使用root用户运行,然而chroot默认使用root用户登录,因此创建一个普通用户,步骤如下: 262 | 263 | ```sh 264 | /sbin/useradd -m testuser 265 | ``` 266 | 267 |   并且切换到该用户 268 | 269 | ```sh 270 | su testuser 271 | ``` 272 | 273 | ##### 执行图形化程序 274 |   因本文下载的系统已经包含了Xorg的图形系统,并有加入了少量的图形应用程序,如果是在Xorg环境下chroot到LoongArch系统中的情况下,可以在该环境下运行LoongArch Linux系统中的图形程序。 275 | 276 |   在运行之前需要设置DISPLAY环境变量,以便图形程序能够链接到Xorg环境,参考如下命令: 277 | 278 | ```sh 279 | export DISPLAY=:0 280 | ``` 281 | 282 |   设置完成后,可以运行一个图形终端程序测试一下,命令: 283 | 284 | ```sh 285 | xterm 286 | ``` 287 | 288 |   XTerm是一个简易的X图形系统下运行的终端程序,如果一切正常的话可以启动XTerm,并显示一个终端窗口,这个终端窗口就是LoongArch系统下的程序执行显示的。 289 | 290 | 291 | ##### 开发环境 292 |   通过以上的方式还可以运行其它程序或图形程序,这包括各种开发工具,由于系统中提供了完整的开发环境,你也可以在LoongArch系统中自行编译某个程序来执行,一切看起来跟用真实的LoongArch机器相似。 293 | 294 | 295 | ## 附件 296 | X86_64系统下的Qemu for loongarch64 linux-user 程序: 297 | 298 | ``` 299 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-x86_64-to-loongarch64 300 | ``` 301 | 302 | 303 | MIPS64EL系统下的Qemu for loongarch64 linux-user 程序: 304 | 305 | ``` 306 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-mips64el-to-loongarch64 307 | ``` 308 | 309 | 310 | 311 | ## 结束 312 | 313 |   本文会根据QEMU支持LoongArch的状况不定期的进行更新。 314 | 315 |   感谢大家支持,欢迎提出宝贵的意见。 316 | 317 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CLFS for LoongArch 2 | 如何交叉编译一个基于LoongArch架构的LFS(Linux From Scratch)系统。 3 | 4 | [更新说明](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/ChangeLog.md) 5 | 6 | 7 | [CLFS_For_LoongArch64 2025.2 文档](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64.md) 8 | 9 | 对应的CLFS系统: 10 | 11 | [CLFS for LoongArch64 2025.2 boot 压缩包] 12 | 13 | [CLFS for LoongArch64 2025.2 sysroot 压缩包] 14 | 15 | 附加包: 16 | 17 | 18 | 以下交叉工具连均默认带gcc编译器。 19 | 20 |   交叉工具链(精简版,不带任何库文件):[loongarch64-clfs-2025.2-cross-tools-c-only] 21 | 22 |   交叉工具链(仅带glibc库支持):[loongarch64-clfs-2025.2-cross-tools-gcc-glibc] 23 | 24 |   交叉工具链(带有对应CLFS系统全部库文件):[loongarch64-clfs-2025.2-cross-tools-gcc-full] 25 | -------------------------------------------------------------------------------- /english/ChangeLog_en.md: -------------------------------------------------------------------------------- 1 | ##### 20210831 2 | -Re-acquire the toolchain code and refactor the entire system 3 | -Remove the "-march=loongarch" compilation parameter, and set the default detection architecture of the toolchain. 4 | -Update the following packages: 5 | Binutils 6 | Diffutils 7 | GCC 8 | Glibc 9 | Grep 10 | Libcap 11 | Linux-Firmware 12 | M4 13 | OpenSSL 14 | ACPI-Update 15 | 16 | -Add the following software packages and building steps: 17 | Boost 18 | Ctags 19 | Ethtool 20 | Fontconfig 21 | Freetype 22 | Fribidi 23 | Glibmm 24 | GnuTLS 25 | Gobject-Introspection 26 | Harfbuzz 27 | Jasper 28 | Lcms 29 | Libaio 30 | Libcap 31 | Libgudev 32 | Libgusb 33 | Libjpeg-Turbo 34 | Libmng 35 | Libnl 36 | Libpng 37 | LibRaw 38 | Libsigc++ 39 | Libtasn1 40 | Libusb 41 | Libunistring 42 | LVM2 43 | Mdadm 44 | Nettle 45 | OpenJPEG 46 | P11-Kit 47 | TIFF 48 | Usbutils 49 | Vala 50 | Wireless-Tools 51 | Wpa_Supplicant 52 | 53 | -Add command steps that need to be executed when the system is used for the first time 54 | 55 | ##### 20210822 56 | -Add building steps for the CMake package 57 | -Add building steps for the CURL software package 58 | -Add building steps for the Dosfstools software package 59 | -Add the building steps for the Doxygen software package 60 | -Add building steps for the Git package 61 | -Add building steps for the Glib software package 62 | -Add building steps for the ICU4C software package 63 | -Add the building steps for the Inih software package 64 | -Add building steps for the Libxml2 software package 65 | -Add building steps for the Libxslt software package 66 | -Add the building steps for the Meson software package 67 | -Add building steps for the NSPR software package 68 | -Add building steps for the NSS software package 69 | -Add building steps for the PCRE software package 70 | -Add building steps for the Python-Pip software package 71 | -Add building steps for the Python-Setuptools software package 72 | -Add building steps for the Sqlite3 software package 73 | -Add building steps for the Sudo package 74 | -Add building steps for the Xfsprogs software package 75 | -Add the building steps for the UnRAR software package 76 | -Add the building steps for the UnZip software package 77 | -Add building steps for the Zip software package 78 | 79 | ##### 20210818 80 | -Add building steps for the Python software package 81 | -Add building steps for the Perl software package 82 | -Add building steps for the XML-Parser software package 83 | -Add building steps for the GPM software package 84 | -Add installation steps for certificate files 85 | -Add building steps for the Libevent software package 86 | -Add building steps for the Links software package 87 | 88 | ##### 20210812 89 | -Binutils and GCC updated after 20210801 are used as the toolchain, which updates part of the LA instruction set 90 | -Update the building steps for the GCC, remove the --with-arch and --with-tls options 91 | -Update the Linux kernel source code building steps that support LoongArch, suitable for the 5.14-rc5 version updated after 2021-08-21, and support the updated toolchain compilation 92 | -Update ld.so.1 generated by GCC and Glibc to ld-linux-loongarch64.so.1 patch 93 | -Update the building steps for the the Grub software package to support the updated toolchain compilation 94 | -Update the Linux-Firmware software package 95 | -Add building steps for the ACPI-Update 96 | -Add the steps of making DHCPCD software package 97 | -Add the building steps for the Inetutils package 98 | -Add building steps for the OpenSSH software package 99 | -Add the building steps for the PCIUtils software package 100 | -Add building steps for the WGet software package 101 | 102 | ##### 20210801 103 | -Use open source Binutils, GCC, Glibc and Linux kernel to make CLFS system. -------------------------------------------------------------------------------- /english/Qemu_For_LoongArch64-Simple_en.md: -------------------------------------------------------------------------------- 1 | #
Use QEMU to run a Linux system based on the LoongArch64 architecture (simplified version)
2 | 3 |
(Qemu For LoongArch64 Simple)
4 | 5 |
Author: Sun Haiyong
6 |
Translator: Andrii Kurdiumov
7 | 8 | ## 1 Introduction 9 | This article is a simplified version of the [Qemu_For_LoongArch64.md](Qemu_For_LoongArch64_en.md) document. 10 | 11 | The purpose of this article is to explain how to use QEMU for running a Linux system based on LoongArch64 through a simple operation. 12 | 13 | ## 2 Environmental preparation 14 | ### Prepare the Linux system 15 | Please prepare a general Linux environment, such as Fedora, Debian, etc. 16 | 17 | ### Download QEMU 18 | Download QEMU that can support LoongArch architecture in Linux environment: 19 | 20 | If your machine is an x86-64 system, then use this download link: 21 | 22 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-x86_64-to-loongarch64 23 | 24 | If you happen to have a Loongson 3A 4000 machine, you can use this download link: 25 | 26 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-mips64el-to-loongarch64 27 | 28 | Please rename the downloaded file to qemu-loongarch64 and store it in the /bin directory. For example, use the command for x86-64 files: 29 | 30 | ```sh 31 | cp qemu-x86_64-to-loongarch64 /bin/qemu-loongarch64 32 | ``` 33 | 34 | #### Download LoongArch Linux system 35 | There is already pre-made LoongArch Linux system on GitHub, use the following steps to download from given address: 36 | 37 | ```sh 38 | cd /tmp 39 | wget -c https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/loongarch64-clfs-system-20210903.tar.bz2 40 | ``` 41 | 42 | The system downloaded above is a Linux system based on the LoongArch instruction set architecture constructed entirely using open source code. 43 | 44 | 45 | #### Unzip LoongArch Linux system 46 | Please use the root user to complete the following decompression steps: 47 | 48 | ```sh 49 | cd /opt 50 | mkdir clfs-os 51 | cd clfs-os 52 | tar xvpf /tmp/loongarch64-clfs-system-20210903.tar.bz2 53 | ``` 54 | After a period of decompression, we have a system based on the LoongArch instruction set in the /opt/clfs-os directory. 55 | 56 | ## 3 Use QEMU 57 | 58 | The next step is to register the LoongArch executable file information in Binfmt, use the following command: 59 | 60 | ```sh 61 | echo ":qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\ xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/bin/qemu-loongarch64:"> /proc/sys/ fs/binfmt_misc/register 62 | ``` 63 | 64 | The above command registers the "header information" of the LoongArch executable file, and specifies that the qualified files will be executed using the "/bin/qemu-loongarch64" command, so this "/bin/qemu-loongarch64" command must be true and effective. 65 | 66 | If you want to know what Binfmt is, you can search on the Internet by yourself, or look at the brief description of the documents mentioned in the introduction. 67 | 68 | #### Chroot to LoongArch system 69 | In order to conveniently chroot to the LoongArch system through the Linux user-mode of QEMU, the registration of the Binfmt function is essential. After the registration is completed, the following one-time steps are required: 70 | 71 | ```sh 72 | cp /bin/qemu-loongarch64 /opt/clfs-os/bin/ 73 | ``` 74 | 75 | We copy the executable file qemu-loongarch64 to the system that needs chroot. This step is very critical, and we must ensure that the relative location of qemu-loongarch64 stored in the chroot system is the same as the directory location of the executable in the current system, so put it in the bin directory. 76 | 77 | Next, when we witness the victory, use a root user or sudo command to chroot: 78 | 79 | ```sh 80 | chroot /opt/clfs-os 81 | ``` 82 | At this time we will see the familiar Bash prompt: 83 | 84 | bash-5.1# 85 | 86 | Try to enter some commands, such as ls, vi, you will find that you can run them directly. 87 | 88 | Then enter: 89 | 90 | ```sh 91 | uname -m 92 | ``` 93 | Will return: 94 | 95 | loongarch 96 | 97 | It represents the architecture of LoongArch being simulated in the current environment. 98 | 99 | Next you can refer to: [Qemu_For_LoongArch64.md](Qemu_For_LoongArch64_en.md) for the usage part in the document. 100 | 101 | ## Finish 102 | 103 | Thank you for your support and welcome your valuable comments. 104 | -------------------------------------------------------------------------------- /english/Qemu_For_LoongArch64_en.md: -------------------------------------------------------------------------------- 1 | #
Use QEMU to run a Linux system based on the LoongArch64 architecture
2 | 3 |
(Qemu For LoongArch64)
4 | 5 |
Author: Sun Haiyong
6 |
Translator: Andrii Kurdiumov
7 | 8 | ## 1 Introduction 9 | Loongson Technology launched a new instruction set architecture LoongArch in 2021. This 64-bit instruction set is called LoongArch64. 10 | The operating system based on the LoongArch64 instruction set needs to run on a machine using the Loongson 3A5000 CPU. If you need simply work without such a machine, you need to use the QEMU emulator. 11 | The goal of this article is to use QEMU to run a Linux system based on LoongArch64 through a step-by-step instructions. 12 | 13 | **At the end of the article, there are compiled QEMU files of different architectures available for download, simplifying the use process. ** 14 | 15 | This article involves some operations related to compiling software. If you want simply use it, you can refer to the simplified version of the document: 16 | [Qemu_For_LoongArch64-Simple.md](Qemu_For_LoongArch64-Simple_en.md) 17 | 18 | ## 2 Compile QEMU 19 | 20 | This article will use the method of compiling the QEMU source code to create a QEMU executable. Because most of the current QEMU systems do not support LoongArch64 instruction set, the next step is to download and compile QEMU. 21 | 22 | ### Prepare the compilation environment 23 | QEMU supports simulating the environment of the target instruction set from different machine instruction architectures, as long as the machine used can run QEMU. Of course, we recommend installing a "normal" Linux for machine used to run QEMU. Because QEMU also needs to be compiled, so operating system must be able to provide a development environment for compiling QEMU. 24 | 25 | Because the Linux system that's used for building QEMU and running LoongArch64 on machines of different architectures has nothing to do with the LoongArch64 architecture itself, the main difference is only in the steps of preparing the compilation environment for the specific Linux system because of the different package management tools used by Linux. Steps are different, but there is almost no difference in using QEMU, so we will explain with an environment using Fedora Linux distribution. 26 | 27 | If you are using an x86 machine, there are many Linux versions to choose from, and if you are using a machine with a non-x86 architecture, you must determine the version that can be used. Next, we will use the Loongson 3A4000 machine to run it. Take Fedora28 as an example to explain how to build and use. Of course, these steps are also suitable for newer versions such as Fedora 32 on 3A4000, or Fedora 34 on x86 machines or other Linux systems. 28 | 29 | #### Create a normal user 30 | It is not recommended to use the root user to compile and build the software package, so we create an ordinary user at the beginning, such as "loongson". If there is already this user in the system, you can create a user with another name or skip this step. 31 | 32 | The creation command is as follows: 33 | 34 | ```sh 35 | useradd -m loongson 36 | ``` 37 | 38 | The use of the parameter "-m" is to create a home directory for this new user, and then we will need to use the user's home directory. 39 | 40 | Note: User creation must be performed by a user with root privileges. 41 | 42 | #### Switch user 43 | After creating a normal user, you can switch to that user and use the following command: 44 | 45 | ```sh 46 | su loongson 47 | ``` 48 | 49 | Switching from the root user to a normal user can avoid entering a password. 50 | 51 | By default, after switching users, it will automatically enter the user's home directory, and subsequent work will be carried out in the home directory. 52 | 53 | ### Download the source code of QEMU 54 | 55 | The code that supports LoongArch64 in QEMU has not yet entered the upstream source code repository of QEMU. Therefore, we need to download a QEMU source code that supports LoongArch64 instructions. 56 | 57 | Use the following command to download the QEMU code: 58 | 59 | ```sh 60 | git clone https://github.com/gaosong-loongson/qemu.git -b tcg-dev 61 | ``` 62 | 63 | After a some time of downloading, we will have the QEMU source code that supports the LoongArch64 instruction set. 64 | 65 | 66 | ### QEMU support mode 67 | The next step is the most critical compilation process. 68 | 69 | Enter the source code directory of QEMU: 70 | 71 | ```sh 72 | cd ~/qemu 73 | ``` 74 | Note: It is assumed that the source code is downloaded to the current user's home directory. 75 | 76 | Next, if the code needs to be patched or corrected, it can be done at this time. For example, the following fixes a problem that may occur during the configuration phase: 77 | 78 | ```sh 79 | sed -i'/compile_prog/s@"\$glib_cflags"@"\$glib_cflags -Werror"@g' configure 80 | ``` 81 | 82 | ```sh 83 | sed -i's@"loongarch"@"loongarch64"@g' linux-user/loongarch64/target_syscall.h 84 | ``` 85 | 86 | QEMU has many compilation parameters, which can be viewed with the following command: 87 | 88 | ```sh 89 | ./configure --help 90 | ``` 91 | 92 | The parameter we care about here is mainly "--target-list". By checking the content supported by this parameter, we will find that QEMU has two main ways to use it, namely: softmmu and Linux user mode, the former is system emulation, and the latter is The simple understanding of Linux user mode simulation is that the former simulates a host, and the latter simulates the Linux kernel environment and can directly run linux commands. 93 | 94 | The opened QEMU source code that supports the LoongArch architecture only supports the Linux User mode, so the next step is to compile and use it according to this mode. 95 | 96 | ### Install and compile dependent environment 97 | Before compiling, you need to install some system software development packages. These packages are needed when compiling QEMU. Usually, the names of packages that are missing in the current system will be given in the ./configure configuration stage. If they are not installed, install them, such if you need glib2 development kit, you can use the following command: 98 | 99 | ```sh 100 | dnf install glib2-devel 101 | ``` 102 | In addition to installing the development files of the necessary software packages, some static libraries are also used for the Linux User mode, so they are should be also installed in the system, for example: 103 | 104 | ```sh 105 | dnf install glib2-static pcre-static zlib-static 106 | ``` 107 | 108 | Note that at this time, you need to use a root-privileged user to install, or add sudo execution permissions to the current user and then install it through the sudo command. 109 | 110 | ### Linux-User Mode 111 | 112 | #### Configuration steps 113 | Use the following steps to configure first: 114 | 115 | ```sh 116 | ./configure --prefix=/usr --target-list=loongarch64-linux-user \ 117 | --disable-werror --static --disable-docs 118 | ``` 119 | Configuration parameter explanation: 120 | ```--prefix=/usr```: Set the base directory for installation. 121 | ```--target-list=loongarch64-linux-user```: This configuration parameter is a key item, here is specified loongarch64-linux-user, "loongarch64" means supporting LoongArch64 architecture, "linux-user" means Linux -User mode. 122 | ```--disable-werror```: Prevent syntax warnings from becoming errors, which may cause errors when compiling QEMU with higher versions of gcc. 123 | ```--static```: This configuration parameter is also a key item. It is used to specify that the compiled binary command file is statically linked. This requires the system to install a static library that compiles the link library files required by QEMU. 124 | ```--disble-docs```: This parameter is not necessary, this parameter is used to cancel the production step of the document file, which can reduce some compilation time. 125 | 126 | In the configuration phase, you need to keep the network status, because the configuration process will need to download some files from the network. This is one-time process is, that is after first configuration phase will be carried out, as long as the software source code directory is not deleted, subsequent reconfiguration would not longer need to download anything. 127 | 128 | #### Compilation steps 129 | Next steps if compilation which is very simple. Just use the make command, as follows: 130 | 131 | ```sh 132 | make 133 | ``` 134 | 135 | Of course, if you want to speed up the compilation, you can add the "-jN" parameter, N needs to be replaced with a certain number, and you can use the number calculated by your current "CPU core number*2+1". 136 | After some time (depending on the performance of the machine) the compilation will be completed. 137 | 138 | #### installation steps 139 | After the compilation is complete, install QEMU. There is no need to use the common make install command to install, because currently we only need an executable file, which is stored in the build directory, switch to root user authority and install it with the following command: 140 | 141 | ```sh 142 | strip --strip-all build/qemu-loongarch64 143 | cp -a build/qemu-loongarch64 /bin/ 144 | ``` 145 | The strip command can be used to strip unnecessary debugging information from an executable file, which can greatly reduce the file size. 146 | 147 | After the qemu-loongarch64 command is copied to the /bin directory, the installation is completed. 148 | 149 | ## 3 Use QEMU 150 | 151 | ### Use of Linux User Mode 152 | 153 | #### Download LoongArch Linux system 154 | There is already pre-made LoongArch Linux system on GitHub, use the following address steps to download: 155 | 156 | ```sh 157 | cd /tmp 158 | wget -c https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/loongarch64-clfs-system-20210903.tar.bz2 159 | ``` 160 | 161 | The system downloaded above is a Linux system based on the LoongArch instruction set architecture constructed entirely using open source codes. 162 | 163 | 164 | #### Unzip the Linux system 165 | Please use the root user to complete the following decompression steps: 166 | 167 | ```sh 168 | cd /opt 169 | mkdir clfs-os 170 | cd clfs-os 171 | tar xvpf /tmp/loongarch64-clfs-system-20210903.tar.bz2 172 | ``` 173 | After a period of decompression, we have a system based on the LoongArch instruction set in the /opt/clfs-os directory. 174 | 175 | #### Test the Linux-User mode of QEMU 176 | After QEMU and Linux system have been installed, you can start to verify whether the Linux-User mode of QEMU is working properly, use the following command: 177 | 178 | ```sh 179 | /bin/qemu-loongarch64 -L /opt/clfs-os /opt/clfs-os/bin/ls / 180 | ``` 181 | 182 | If the command can be executed normally and the contents of the current system root directory are listed, it means that the Linux User mode of QEMU can be used. 183 | 184 | #### Register Binfmt Information 185 | When we test the use of Linux User mode, we will find that in order to execute a command, we need to specify related parameters. This makes when we want to try to chroot into this system, we will cause a lot of problems because of these additional parameter specifications. Can the problem that is convenient for handling be used like the command in the current system? 186 | 187 | The answer is of course yes, the solution is to use Binfmt to execute. 188 | 189 | In simple terms, Binfmt is to register the "header information" of an executable file in the kernel. When the executed executable file matches the registered "header information", it will call the command execution file specified during registration. 190 | 191 | As can be seen from the above description, Binfmt needs kernel support before it can be used, so first confirm whether the following current system supports it, and use the command: 192 | 193 | ```sh 194 | ls /proc/sys/fs/binfmt_misc/ 195 | ``` 196 | If it shows that there are the following files in the directory: 197 | ```register status``` 198 | To check if Binfmt function is turned on, look at the content of the following status file: 199 | 200 | ```sh 201 | cat /proc/sys/fs/binfmt_misc/status 202 | ``` 203 | 204 | If it is displayed as ```enable```, it means that the Binfmt function is currently supported and available by the kernel. 205 | 206 | The next step is to register the LoongArch executable file information, use the following command: 207 | 208 | ```sh 209 | echo ":qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\ xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/bin/qemu-loongarch64:"> /proc/sys/ fs/binfmt_misc/register 210 | ``` 211 | 212 | The above command registers the "header information" of the LoongArch executable file, and specifies that the qualified files will be executed using the "/bin/qemu-loongarch64" command, so this "/bin/qemu-loongarch64" command must be true and effective. 213 | 214 | #### Chroot to LoongArch system 215 | In order to conveniently chroot to the LoongArch system through the Linux-User mode of QEMU, the registration of the Binfmt function is essential. After the registration is completed, the following one-time steps are required: 216 | 217 | ```sh 218 | cp /bin/qemu-loongarch64 /opt/clfs-os/bin/ 219 | ``` 220 | 221 | We copy the executable file qemu-loongarch64 to the system that needs chroot. This step is very important, and we must ensure that the relative location of qemu-loongarch64 stored in the chroot system is the same as the directory location of the command in the current system, is the same as what is given to Binfmt. Only in this way can the Binfmt function can find the correct simulator command after chrooting to the new system. 222 | 223 | Next, when we see success, use a root user or sudo command to chroot: 224 | 225 | ```sh 226 | chroot /opt/clfs-os 227 | ``` 228 | At this time we will see the familiar Bash prompt: 229 | 230 | bash-5.1# 231 | 232 | Try to enter some commands, such as ls, vi, you will find that you can run it directly. 233 | 234 | Then enter: 235 | 236 | ```sh 237 | uname -m 238 | ``` 239 | Will return: 240 | 241 | loongarch64 242 | 243 | It represents the architecture of LoongArch being simulated in the current environment. 244 | 245 | 246 | #### Graphical program execution 247 | In the LoongArch system we provide, if it is a command used in a terminal, it can be easily executed and operated, just like a program for local architecture, but what if you want to execute some programs in a graphical environment? 248 | 249 | Next, we will try to run a terminal program under a graphics system as an example. 250 | 251 | ##### Mount the necessary file system 252 | For a chrooted system, the lack of necessary file systems will affect the operation of some programs. You can mount several necessary file systems after chrooting. The steps are as follows: 253 | 254 | ```sh 255 | mount -t proc proc /proc 256 | mount -t sysfs sys /sys 257 | mount -t devtmpfs dev /dev 258 | mount -t devpts devpts /dev/pts 259 | ``` 260 | 261 | ##### Create a normal user 262 | Some programs in the system have certain requirements for users. For example, they cannot be run as the root user. However, chroot uses the root user to log in by default. Therefore, to create an ordinary user, the steps are as follows: 263 | 264 | ```sh 265 | /sbin/useradd -m testuser 266 | ``` 267 | 268 | And switch to that user 269 | 270 | ```sh 271 | su testuser 272 | ``` 273 | 274 | ##### Execute graphical program 275 | Because the system downloaded in this article already includes the Xorg graphics system, and a small amount of graphics applications have been added, if you chroot to the LoongArch system in the Xorg environment, you can run the graphics in the LoongArch Linux system in this environment program. 276 | 277 | Before running, you need to set the DISPLAY environment variable so that the graphics program can be linked to the Xorg environment. Refer to the following command: 278 | 279 | ```sh 280 | export DISPLAY=:0 281 | ``` 282 | 283 | After setting, you can run a graphical terminal program to test it, command: 284 | 285 | ```sh 286 | xterm 287 | ``` 288 | 289 | XTerm is a simple terminal program that runs under the X graphics system. If everything is normal, you can start XTerm and display a terminal window. This terminal window is displayed by the program execution under the LoongArch system. 290 | 291 | 292 | ##### Development environment 293 | Through the above methods, you can also run other programs or graphics programs, including various development tools. Since the system provides a complete development environment, you can also compile a program in the LoongArch system to execute it, and everything looks the same. The real LoongArch machine is similar. 294 | 295 | 296 | ## Appendix 297 | Qemu for loongarch64 linux-user program under X86_64 system: 298 | 299 | ``` 300 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-x86_64-to-loongarch64 301 | ``` 302 | 303 | 304 | Qemu for loongarch64 linux-user program under MIPS64EL system: 305 | 306 | ``` 307 | https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210903/qemu-mips64el-to-loongarch64 308 | ``` 309 | 310 | 311 | 312 | ## Finish 313 | 314 | This article will be updated from time to time based on QEMU's support for LoongArch. 315 | 316 | Thank you for your support and welcome your valuable comments. 317 | -------------------------------------------------------------------------------- /english/README_en.md: -------------------------------------------------------------------------------- 1 | # CLFS-for-LoongArch 2 | 3 | How to cross compile a LFS system (Linux From Scratch) based on the LoongArch architecture. 4 | 5 | [Chinese version](README.md) 6 | 7 | [Change log](ChangeLog_en.md) 8 | 9 | ## Snapshots 10 | 11 | [CLFS_For_LoongArch64-20210831](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64-20210831.md): 12 | 13 | Corresponding CLFS system: [loongarch64-clfs-system-20210831](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210831/loongarch64-clfs-system-20210831.tar.bz2) 14 | 15 | Cross-compile toolchain: [loongarch64-clfs-20210831-cross-tools](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210831/loongarch64-clfs-20210831-cross-tools.tar.xz) 16 | 17 | [CLFS_For_LoongArch64-20210822](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64-20210822.md): 18 | 19 | Corresponding CLFS system: [loongarch64-clfs-system-20210822](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210822/loongarch64-clfs-system-20210822.tar.bz2) 20 | 21 | Cross-compile toolchain: [loongarch64-clfs-20210812-cross-tools](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210812/loongarch64-clfs-20210812-cross-tools.tar.xz) 22 | 23 | [CLFS_For_LoongArch64-20210818](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64-20210818.md): 24 | 25 | Corresponding CLFS system: [loongarch64-clfs-system-20210818](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210818/loongarch64-clfs-system-20210818.tar.bz2) 26 | 27 | Cross-compile toolchain: [loongarch64-clfs-20210812-cross-tools](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210812/loongarch64-clfs-20210812-cross-tools.tar.xz) 28 | 29 | 30 | [CLFS_For_LoongArch64-20210812](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64-20210812.md): 31 | 32 | Corresponding CLFS system: [loongarch64-clfs-system-20210812](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210812/loongarch64-clfs-system-20210812.tar.bz2) 33 | 34 | Cross-compile toolchain: [loongarch64-clfs-20210812-cross-tools](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210812/loongarch64-clfs-20210812-cross-tools.tar.xz) 35 | 36 | 37 | [CLFS_For_LoongArch64-20210801](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/blob/main/CLFS_For_LoongArch64-20210801.md): 38 | 39 | Corresponding CLFS system: [loongarch64-clfs-system-20210801](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210801/loongarch64-clfs-system-20210801.tar.bz2) 40 | 41 | Cross-compile toolchain: [loongarch64-clfs-20210801-cross-tools](https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/20210801/loongarch64-clfs-20210801-cross-tools.tar.xz) 42 | -------------------------------------------------------------------------------- /patches/0001-Add-the-missing-LoongArch-definition-in-the-v8.gyp-f.patch: -------------------------------------------------------------------------------- 1 | From dce3df4fe6f3561c2a97030552834bc4afe0dea4 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Thu, 20 Apr 2023 11:58:42 +0000 4 | Subject: [PATCH] Add the missing LoongArch definition in the v8.gyp file of 5 | V8. 6 | 7 | --- 8 | tools/v8_gypfiles/v8.gyp | 5 +++++ 9 | 1 file changed, 5 insertions(+) 10 | 11 | diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp 12 | index 4ed21761..6f04ec21 100644 13 | --- a/tools/v8_gypfiles/v8.gyp 14 | +++ b/tools/v8_gypfiles/v8.gyp 15 | @@ -725,6 +725,11 @@ 16 | ' 3 | Date: Tue, 16 May 2023 02:06:04 +0000 4 | Subject: [PATCH] Fix english db build error. 5 | 6 | --- 7 | data/db/english/english.awk | 4 ++-- 8 | 1 file changed, 2 insertions(+), 2 deletions(-) 9 | 10 | diff --git a/data/db/english/english.awk b/data/db/english/english.awk 11 | index 1828d2c..ff1cbb1 100644 12 | --- a/data/db/english/english.awk 13 | +++ b/data/db/english/english.awk 14 | @@ -16,10 +16,10 @@ BEGIN { 15 | } 16 | 17 | # Insert data into english table 18 | - { printf "INSERT INTO english (word, freq) VALUES (\"%s\", \"%f\");\n", $1, $2} 19 | + { printf "INSERT INTO english (word, freq) VALUES ('%s', '%f');\n", $1, $2} 20 | 21 | #quit sqlite3 22 | END { 23 | # Commit the transcation 24 | print "COMMIT;" 25 | -} 26 | \ No newline at end of file 27 | +} 28 | -- 29 | 2.31.1 30 | 31 | -------------------------------------------------------------------------------- /patches/0001-Fix-loongarch64-double-float-define-to-loongarch64-l.patch: -------------------------------------------------------------------------------- 1 | From a2c2144b5af770b8f935a93af83450c78d9c85ee Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Tue, 16 May 2023 01:26:16 +0000 4 | Subject: [PATCH] Fix loongarch64 double float define to loongarch64-linux-gnu. 5 | 6 | --- 7 | src/basic/architecture.h | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/src/basic/architecture.h b/src/basic/architecture.h 11 | index c8ffcc5..f7d795b 100644 12 | --- a/src/basic/architecture.h 13 | +++ b/src/basic/architecture.h 14 | @@ -203,7 +203,7 @@ Architecture uname_architecture(void); 15 | #elif defined(__loongarch64) 16 | # define native_architecture() ARCHITECTURE_LOONGARCH64 17 | # if defined(__loongarch_double_float) 18 | -# define LIB_ARCH_TUPLE "loongarch64-linux-gnuf64" 19 | +# define LIB_ARCH_TUPLE "loongarch64-linux-gnu" 20 | # elif defined(__loongarch_single_float) 21 | # define LIB_ARCH_TUPLE "loongarch64-linux-gnuf32" 22 | # elif defined(__loongarch_soft_float) 23 | -- 24 | 2.31.1 25 | 26 | -------------------------------------------------------------------------------- /patches/0001-QT-5.15.8-add-loongarch64-support.patch: -------------------------------------------------------------------------------- 1 | From 860c6d8475e98f59e7e8c9023fc421f4986c2378 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Fri, 3 Mar 2023 03:51:55 +0000 4 | Subject: [PATCH] QT 5.15.8 add loongarch64 support. 5 | 6 | --- 7 | qtbase/src/corelib/global/archdetect.cpp | 2 ++ 8 | qtbase/src/corelib/global/qglobal.cpp | 10 ++++++++++ 9 | qtbase/src/corelib/global/qprocessordetection.h | 13 +++++++++++++ 10 | 3 files changed, 25 insertions(+) 11 | 12 | diff --git a/qtbase/src/corelib/global/archdetect.cpp b/qtbase/src/corelib/global/archdetect.cpp 13 | index 1d00b7f5a5..74f3c8fc86 100644 14 | --- a/qtbase/src/corelib/global/archdetect.cpp 15 | +++ b/qtbase/src/corelib/global/archdetect.cpp 16 | @@ -59,6 +59,8 @@ 17 | # define ARCH_PROCESSOR "x86_64" 18 | #elif defined(Q_PROCESSOR_IA64) 19 | # define ARCH_PROCESSOR "ia64" 20 | +#elif defined(Q_PROCESSOR_LOONGARCH_64) 21 | +# define ARCH_PROCESSOR "loongarch64" 22 | #elif defined(Q_PROCESSOR_MIPS_64) 23 | # define ARCH_PROCESSOR "mips64" 24 | #elif defined(Q_PROCESSOR_MIPS) 25 | diff --git a/qtbase/src/corelib/global/qglobal.cpp b/qtbase/src/corelib/global/qglobal.cpp 26 | index ac2e85c51e..0c3524804f 100644 27 | --- a/qtbase/src/corelib/global/qglobal.cpp 28 | +++ b/qtbase/src/corelib/global/qglobal.cpp 29 | @@ -1815,6 +1815,16 @@ bool qSharedBuild() noexcept 30 | \sa QSysInfo::buildCpuArchitecture() 31 | */ 32 | 33 | +/*! 34 | + \macro Q_PROCESSOR_LOONGARCH 35 | + \relates 36 | + 37 | + Defined if the application is compiled for LOONGARCH processors. Qt currently 38 | + supports seven LOONGARCH revisions: Q_PROCESSOR_LOONGARCH_64. 39 | + 40 | + \sa QSysInfo::buildCpuArchitecture() 41 | +*/ 42 | + 43 | /*! 44 | \macro Q_PROCESSOR_MIPS 45 | \relates 46 | diff --git a/qtbase/src/corelib/global/qprocessordetection.h b/qtbase/src/corelib/global/qprocessordetection.h 47 | index 8d65720850..680265f1aa 100644 48 | --- a/qtbase/src/corelib/global/qprocessordetection.h 49 | +++ b/qtbase/src/corelib/global/qprocessordetection.h 50 | @@ -213,6 +213,19 @@ 51 | # define Q_BYTE_ORDER Q_LITTLE_ENDIAN 52 | # define Q_PROCESSOR_WORDSIZE 8 53 | 54 | +/* 55 | + LoongArch family, known variants: 64-bit 56 | + 57 | + LoongArch is little-endian. 58 | +*/ 59 | +#elif defined(__loongarch__) 60 | +# define Q_PROCESSOR_LOONGARCH 61 | +# if __loongarch_grlen == 64 62 | +# define Q_PROCESSOR_LOONGARCH_64 63 | +# endif 64 | +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN 65 | +# define Q_PROCESSOR_WORDSIZE 8 66 | + 67 | /* 68 | Itanium (IA-64) family, no revisions or variants 69 | 70 | -- 71 | 2.31.1 72 | 73 | -------------------------------------------------------------------------------- /patches/0001-enable-cross-compilation.patch: -------------------------------------------------------------------------------- 1 | From: Andrew Ruder 2 | Subject: [PATCH] enable cross compilation for expect 3 | 4 | This patch was created by running ./configure on a modern Linux machine 5 | and inserting the results into the cross compilation section of 6 | each AC_MSG_CHECKING that bombed out with an error. 7 | 8 | Signed-off-by: Andrew Ruder 9 | --- 10 | 11 | Index: expect-5.45/configure.in 12 | =================================================================== 13 | --- expect-5.45.orig/configure.in 2013-11-14 07:59:58.732100595 -0600 14 | +++ expect-5.45/configure.in 2013-11-14 07:59:58.732100595 -0600 15 | @@ -481,7 +481,7 @@ 16 | , 17 | AC_MSG_RESULT(no) 18 | , 19 | - AC_MSG_ERROR([Expect can't be cross compiled]) 20 | + AC_MSG_RESULT(no) 21 | ) 22 | 23 | AC_MSG_CHECKING([if any value exists for WNOHANG]) 24 | @@ -506,7 +506,8 @@ 25 | AC_MSG_RESULT(no) 26 | AC_DEFINE(WNOHANG_BACKUP_VALUE, 1) 27 | , 28 | - AC_MSG_ERROR([Expect can't be cross compiled]) 29 | + AC_MSG_RESULT(yes) 30 | + AC_DEFINE(WNOHANG_BACKUP_VALUE, 1) 31 | ) 32 | 33 | # 34 | @@ -574,7 +575,7 @@ 35 | AC_DEFINE(REARM_SIG) 36 | , 37 | AC_MSG_RESULT(no) 38 | -, AC_MSG_WARN([Expect can't be cross compiled]) 39 | +, AC_MSG_RESULT(no) 40 | ) 41 | 42 | # HPUX7 has trouble with the big cat so split it 43 | @@ -725,7 +726,7 @@ 44 | , 45 | AC_MSG_RESULT(no) 46 | , 47 | - AC_MSG_ERROR([Expect can't be cross compiled]) 48 | + AC_MSG_RESULT(no) 49 | ) 50 | 51 | # mach systems have include files for unimplemented features 52 | @@ -749,7 +750,9 @@ 53 | , 54 | AC_MSG_RESULT(no) 55 | , 56 | - AC_MSG_ERROR([Expect can't be cross compiled]) 57 | + AC_DEFINE(HAVE_TERMIO) 58 | + PTY_TYPE=termios 59 | + AC_MSG_RESULT(yes) 60 | ) 61 | 62 | # now check for the new style ttys (not yet posix) 63 | @@ -771,7 +774,9 @@ 64 | , 65 | AC_MSG_RESULT(no) 66 | , 67 | - AC_MSG_ERROR([Expect can't be cross compiled]) 68 | + AC_DEFINE(HAVE_TERMIOS) 69 | + PTY_TYPE=termios 70 | + AC_MSG_RESULT(yes) 71 | ) 72 | fi 73 | 74 | @@ -794,7 +799,7 @@ 75 | , 76 | AC_MSG_RESULT(no) 77 | , 78 | - AC_MSG_ERROR([Expect can't be cross compiled]) 79 | + AC_MSG_RESULT(no) 80 | ) 81 | 82 | AC_MSG_CHECKING([if TIOCGWINSZ in termios.h]) 83 | @@ -816,7 +821,7 @@ 84 | , 85 | AC_MSG_RESULT(no) 86 | , 87 | - AC_MSG_ERROR([Expect can't be cross compiled]) 88 | + AC_MSG_RESULT(no) 89 | ) 90 | 91 | # finally check for Cray style ttys 92 | @@ -837,7 +842,7 @@ 93 | , 94 | AC_MSG_RESULT(no) 95 | , 96 | - AC_MSG_ERROR([Expect can't be cross compiled]) 97 | + AC_MSG_RESULT(no) 98 | ) 99 | 100 | # 101 | @@ -869,7 +874,9 @@ 102 | AC_HAVE_FUNCS(getpty) 103 | 104 | # following test sets SETPGRP_VOID if setpgrp takes 0 args, else takes 2 105 | -AC_FUNC_SETPGRP 106 | +cat >>expect_cf.h <<\_ACEOF 107 | +#define SETPGRP_VOID 1 108 | +_ACEOF 109 | 110 | # 111 | # check for timezones 112 | @@ -889,7 +896,7 @@ 113 | AC_MSG_RESULT(yes), 114 | AC_MSG_RESULT(no) 115 | , 116 | - AC_MSG_ERROR([Expect can't be cross compiled]) 117 | + AC_MSG_RESULT(yes) 118 | ) 119 | 120 | 121 | -------------------------------------------------------------------------------- /patches/0001-ibus-1.5.28-change-for-cross-compiler.patch: -------------------------------------------------------------------------------- 1 | From 8e8586590c93db2c794918bc7b50740d38d54b8f Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Wed, 1 Mar 2023 09:48:26 +0000 4 | Subject: [PATCH] ibus 1.5.28 change for cross compiler. 5 | 6 | --- 7 | configure.ac | 28 +--------------------------- 8 | src/Makefile.am | 2 +- 9 | 2 files changed, 2 insertions(+), 28 deletions(-) 10 | 11 | diff --git a/configure.ac b/configure.ac 12 | index f446ae9..5a1427e 100644 13 | --- a/configure.ac 14 | +++ b/configure.ac 15 | @@ -152,33 +152,7 @@ AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")]) 16 | AC_SUBST(LIBDL) 17 | 18 | # Check endianness. 19 | -AC_MSG_CHECKING([build system endianness]) 20 | -ENDIAN=unknown 21 | -AC_RUN_IFELSE( 22 | - [AC_LANG_PROGRAM( 23 | - [[ 24 | - #include 25 | - #if __BYTE_ORDER != __LITTLE_ENDIAN 26 | - #error 27 | - #endif 28 | - ]] 29 | - )], 30 | - [ENDIAN=little] 31 | -) 32 | -AC_RUN_IFELSE( 33 | - [AC_LANG_PROGRAM( 34 | - [[ 35 | - #include 36 | - #if __BYTE_ORDER != __BIG_ENDIAN 37 | - #error 38 | - #endif 39 | - ]] 40 | - )], 41 | - [ENDIAN=big] 42 | -) 43 | -if test x"$ENDIAN" != xlittle -a x"$ENDIAN" != xbig; then 44 | - AC_MSG_ERROR([Cannot deermine endianness without endian.h]) 45 | -fi 46 | +ENDIAN=little 47 | AC_MSG_RESULT($ENDIAN) 48 | AC_SUBST(ENDIAN) 49 | 50 | diff --git a/src/Makefile.am b/src/Makefile.am 51 | index 426376d..d25953d 100644 52 | --- a/src/Makefile.am 53 | +++ b/src/Makefile.am 54 | @@ -270,7 +270,7 @@ ibus.gresources.xml: ibus.gresources.xml.in 55 | 56 | compose/sequences-$(ENDIAN)-endian: gen-internal-compose-table 57 | $(AM_V_GEN) $(MKDIR_P) $(builddir)/compose && \ 58 | - $(builddir)/gen-internal-compose-table && \ 59 | + qemu-loongarch64 $(builddir)/gen-internal-compose-table && \ 60 | mv $(builddir)/sequences-big-endian $(builddir)/compose && \ 61 | mv $(builddir)/sequences-little-endian $(builddir)/compose 62 | 63 | -- 64 | 2.31.1 65 | 66 | -------------------------------------------------------------------------------- /patches/0001-librsvg-2.54.5-fix-loongarch64-support.patch: -------------------------------------------------------------------------------- 1 | From c9513f5c0de0098fe713fdedbe4730ac0b264374 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Tue, 20 Sep 2022 08:22:26 +0000 4 | Subject: [PATCH] librsvg 2.54.5 fix loongarch64 support. 5 | 6 | --- 7 | vendor/cfg-expr/src/targets/builtins.rs | 13 +++++++++++++ 8 | .../linux_like/linux/gnu/b64/loongarch64/mod.rs | 7 +------ 9 | 2 files changed, 14 insertions(+), 6 deletions(-) 10 | 11 | diff --git a/vendor/cfg-expr/src/targets/builtins.rs b/vendor/cfg-expr/src/targets/builtins.rs 12 | index 74ee0a4..fecd5c8 100644 13 | --- a/vendor/cfg-expr/src/targets/builtins.rs 14 | +++ b/vendor/cfg-expr/src/targets/builtins.rs 15 | @@ -973,6 +973,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ 16 | has_atomics: HasAtomics::atomic_8_16_32_64_ptr, 17 | panic: Panic::unwind, 18 | }, 19 | + TargetInfo { 20 | + triple: Triple::new_const("loongarch64-unknown-linux-gnu"), 21 | + os: Some(Os::linux), 22 | + arch: Arch::loongarch64, 23 | + env: Some(Env::gnu), 24 | + vendor: Some(Vendor::unknown), 25 | + families: Families::unix, 26 | + pointer_width: 64, 27 | + endian: Endian::little, 28 | + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, 29 | + panic: Panic::unwind, 30 | + }, 31 | TargetInfo { 32 | triple: Triple::new_const("m68k-unknown-linux-gnu"), 33 | os: Some(Os::linux), 34 | @@ -2181,6 +2193,7 @@ impl super::Arch { 35 | pub const avr: Arch = Arch::new_const("avr"); 36 | pub const bpf: Arch = Arch::new_const("bpf"); 37 | pub const hexagon: Arch = Arch::new_const("hexagon"); 38 | + pub const loongarch64: Arch = Arch::new_const("loongarch64"); 39 | pub const m68k: Arch = Arch::new_const("m68k"); 40 | pub const mips: Arch = Arch::new_const("mips"); 41 | pub const mips64: Arch = Arch::new_const("mips64"); 42 | diff --git a/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs 43 | index 2ed6a91..8ca3dca 100644 44 | --- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs 45 | +++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs 46 | @@ -325,8 +325,6 @@ pub const SYS_vmsplice: ::c_long = 75; 47 | pub const SYS_splice: ::c_long = 76; 48 | pub const SYS_tee: ::c_long = 77; 49 | pub const SYS_readlinkat: ::c_long = 78; 50 | -pub const SYS_newfstatat: ::c_long = 79; 51 | -pub const SYS_fstat: ::c_long = 80; 52 | pub const SYS_sync: ::c_long = 81; 53 | pub const SYS_fsync: ::c_long = 82; 54 | pub const SYS_fdatasync: ::c_long = 83; 55 | @@ -409,8 +407,6 @@ pub const SYS_setgroups: ::c_long = 159; 56 | pub const SYS_uname: ::c_long = 160; 57 | pub const SYS_sethostname: ::c_long = 161; 58 | pub const SYS_setdomainname: ::c_long = 162; 59 | -pub const SYS_getrlimit: ::c_long = 163; 60 | -pub const SYS_setrlimit: ::c_long = 164; 61 | pub const SYS_getrusage: ::c_long = 165; 62 | pub const SYS_umask: ::c_long = 166; 63 | pub const SYS_prctl: ::c_long = 167; 64 | @@ -490,7 +486,6 @@ pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; 65 | pub const SYS_perf_event_open: ::c_long = 241; 66 | pub const SYS_accept4: ::c_long = 242; 67 | pub const SYS_recvmmsg: ::c_long = 243; 68 | -//pub const SYS_arch_specific_syscall: ::c_long = 244; 69 | pub const SYS_wait4: ::c_long = 260; 70 | pub const SYS_prlimit64: ::c_long = 261; 71 | pub const SYS_fanotify_init: ::c_long = 262; 72 | @@ -551,7 +546,7 @@ pub const SYS_landlock_add_rule: ::c_long = 445; 73 | pub const SYS_landlock_restrict_self: ::c_long = 446; 74 | pub const SYS_process_mrelease: ::c_long = 448; 75 | pub const SYS_futex_waitv: ::c_long = 449; 76 | -//pub const SYS_set_mempolicy_home_node: ::c_long = 450; 77 | +pub const SYS_set_mempolicy_home_node: ::c_long = 450; 78 | 79 | pub const POSIX_FADV_DONTNEED: ::c_int = 4; 80 | pub const POSIX_FADV_NOREUSE: ::c_int = 5; 81 | -- 82 | 2.31.1 83 | 84 | -------------------------------------------------------------------------------- /patches/0001-mozjs-91-add-loongarch64-supprot.patch: -------------------------------------------------------------------------------- 1 | From f7e509ffd86d097637b2eaf21330b95cf56bf608 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Wed, 19 Oct 2022 07:12:21 +0000 4 | Subject: [PATCH] mozjs 91 add loongarch64 supprot. 5 | 6 | --- 7 | build/gyp_base.mozbuild | 1 + 8 | build/moz.configure/init.configure | 3 +++ 9 | js/src/configure.in | 0 10 | js/src/jit/AtomicOperations.h | 2 +- 11 | mfbt/double-conversion/double-conversion/utils.h | 1 + 12 | mfbt/tests/TestPoisonArea.cpp | 3 +++ 13 | python/mozbuild/mozbuild/configure/constants.py | 2 ++ 14 | 7 files changed, 11 insertions(+), 1 deletion(-) 15 | mode change 100644 => 100755 js/src/configure.in 16 | 17 | diff --git a/build/gyp_base.mozbuild b/build/gyp_base.mozbuild 18 | index 83cd272e10..d47d702298 100644 19 | --- a/build/gyp_base.mozbuild 20 | +++ b/build/gyp_base.mozbuild 21 | @@ -32,6 +32,7 @@ arches = { 22 | 'x86_64': 'x64', 23 | 'x86': 'ia32', 24 | 'aarch64': 'arm64', 25 | + 'loongarch64': 'loongarch64', 26 | 'ppc64': 'ppc64le' if CONFIG['TARGET_ENDIANNESS'] == 'little' else 'ppc64', 27 | } 28 | 29 | diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure 30 | index 3a164c6558..b3e9890749 100644 31 | --- a/build/moz.configure/init.configure 32 | +++ b/build/moz.configure/init.configure 33 | @@ -768,6 +768,9 @@ def split_triplet(triplet, allow_msvc=False, allow_wasi=False): 34 | elif cpu in ("riscv64", "riscv64gc"): 35 | canonical_cpu = "riscv64" 36 | endianness = "little" 37 | + elif cpu.startswith('loongarch64'): 38 | + canonical_cpu = 'loongarch64' 39 | + endianness = 'little' 40 | elif cpu == "sh4": 41 | canonical_cpu = "sh4" 42 | endianness = "little" 43 | diff --git a/js/src/configure.in b/js/src/configure.in 44 | old mode 100644 45 | new mode 100755 46 | diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h 47 | index f4a5727d05..d620d0a6b6 100644 48 | --- a/js/src/jit/AtomicOperations.h 49 | +++ b/js/src/jit/AtomicOperations.h 50 | @@ -381,7 +381,7 @@ constexpr inline bool AtomicOperations::isLockfreeJS(int32_t size) { 51 | #elif defined(__ppc__) || defined(__PPC__) || defined(__sparc__) || \ 52 | defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \ 53 | defined(__PPC64LE__) || defined(__alpha__) || defined(__hppa__) || \ 54 | - defined(__sh__) || defined(__s390__) || defined(__s390x__) || \ 55 | + defined(__loongarch_lp64) || defined(__sh__) || defined(__s390__) || defined(__s390x__) || \ 56 | defined(__m68k__) || defined(__riscv) || defined(__wasi__) 57 | # include "jit/shared/AtomicOperations-feeling-lucky.h" 58 | #else 59 | diff --git a/mfbt/double-conversion/double-conversion/utils.h b/mfbt/double-conversion/double-conversion/utils.h 60 | index 6022132e2b..dd4a392161 100644 61 | --- a/mfbt/double-conversion/double-conversion/utils.h 62 | +++ b/mfbt/double-conversion/double-conversion/utils.h 63 | @@ -107,6 +107,7 @@ int main(int argc, char** argv) { 64 | #if defined(_M_X64) || defined(__x86_64__) || \ 65 | defined(__ARMEL__) || defined(__avr32__) || defined(_M_ARM) || defined(_M_ARM64) || \ 66 | defined(__hppa__) || defined(__ia64__) || \ 67 | + defined(__loongarch__) || \ 68 | defined(__mips__) || \ 69 | defined(__nios2__) || defined(__ghs) || \ 70 | defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \ 71 | diff --git a/mfbt/tests/TestPoisonArea.cpp b/mfbt/tests/TestPoisonArea.cpp 72 | index 96af108037..89a02356ee 100644 73 | --- a/mfbt/tests/TestPoisonArea.cpp 74 | +++ b/mfbt/tests/TestPoisonArea.cpp 75 | @@ -147,6 +147,9 @@ 76 | #elif defined __hppa 77 | # define RETURN_INSTR 0xe840c002 /* bv,n r0(rp) */ 78 | 79 | +#elif defined __loongarch64 80 | +# define RETURN_INSTR 0x4c000020 /* jirl */ 81 | + 82 | #elif defined __mips 83 | # define RETURN_INSTR 0x03e00008 /* jr ra */ 84 | 85 | diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py 86 | index 9f7a977f61..1b531e2e77 100644 87 | --- a/python/mozbuild/mozbuild/configure/constants.py 88 | +++ b/python/mozbuild/mozbuild/configure/constants.py 89 | @@ -47,6 +47,7 @@ CPU_bitness = { 90 | "arm": 32, 91 | "hppa": 32, 92 | "ia64": 64, 93 | + "loongarch64": 64, 94 | "m68k": 32, 95 | "mips32": 32, 96 | "mips64": 64, 97 | @@ -83,6 +84,7 @@ CPU_preprocessor_checks = OrderedDict( 98 | ("arm", "__arm__ || _M_ARM"), 99 | ("aarch64", "__aarch64__ || _M_ARM64"), 100 | ("ia64", "__ia64__"), 101 | + ('loongarch64', '__loongarch_lp64'), 102 | ("s390x", "__s390x__"), 103 | ("s390", "__s390__"), 104 | ("ppc64", "__powerpc64__"), 105 | -- 106 | 2.31.1 107 | 108 | -------------------------------------------------------------------------------- /patches/0001-qt5-5.15-add-stdint-for-compiler-use-gcc-13.patch: -------------------------------------------------------------------------------- 1 | From e5da1d076ab2e0c234f09800be11578344f3ca2c Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Sat, 22 Oct 2022 04:34:17 +0000 4 | Subject: [PATCH] qt5 5.15 add stdint for compiler use gcc 13. 5 | 6 | --- 7 | .../src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp | 1 + 8 | .../src/3rdparty/mapbox-gl-native/include/mbgl/util/string.hpp | 1 + 9 | .../src/3rdparty/mapbox-gl-native/src/mbgl/gl/stencil_mode.hpp | 1 + 10 | 3 files changed, 3 insertions(+) 11 | 12 | diff --git a/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp b/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp 13 | index a28c59a..c20b125 100644 14 | --- a/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp 15 | +++ b/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp 16 | @@ -3,6 +3,7 @@ 17 | #include 18 | #include 19 | #include 20 | +#include 21 | 22 | namespace mbgl { 23 | 24 | diff --git a/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/string.hpp b/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/string.hpp 25 | index 13498cc..5a5e0b6 100644 26 | --- a/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/string.hpp 27 | +++ b/qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/string.hpp 28 | @@ -5,6 +5,7 @@ 29 | #include 30 | #include 31 | #include 32 | +#include 33 | 34 | // Polyfill needed by Qt when building for Android with GCC 35 | #if defined(__ANDROID__) && defined(__GLIBCXX__) 36 | diff --git a/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/gl/stencil_mode.hpp b/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/gl/stencil_mode.hpp 37 | index bc959c9..7e67cf0 100644 38 | --- a/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/gl/stencil_mode.hpp 39 | +++ b/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/gl/stencil_mode.hpp 40 | @@ -1,6 +1,7 @@ 41 | #pragma once 42 | 43 | #include 44 | +#include 45 | 46 | namespace mbgl { 47 | namespace gl { 48 | -- 49 | 2.31.1 50 | 51 | -------------------------------------------------------------------------------- /patches/0001-rustc-1.69.0-add-loongarch-support.patch: -------------------------------------------------------------------------------- 1 | From aa99e5592f6f5bce4a09ccb2a2502f75b9e82b84 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Fri, 21 Apr 2023 14:00:01 +0000 4 | Subject: [PATCH] rustc 1.69.0 add loongarch support 5 | 6 | --- 7 | .../rustc_codegen_ssa/src/back/metadata.rs | 5 + 8 | compiler/rustc_llvm/build.rs | 1 + 9 | .../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 7 + 10 | compiler/rustc_llvm/src/lib.rs | 8 ++ 11 | .../src/spec/loongarch64_unknown_linux_gnu.rs | 19 +++ 12 | compiler/rustc_target/src/spec/mod.rs | 1 + 13 | library/std/src/env.rs | 1 + 14 | library/std/src/os/linux/raw.rs | 3 +- 15 | library/std/src/personality/gcc.rs | 3 + 16 | library/std/src/sys/common/alloc.rs | 1 + 17 | library/unwind/src/libunwind.rs | 3 + 18 | src/bootstrap/bootstrap.py | 1 + 19 | src/bootstrap/lib.rs | 2 +- 20 | src/bootstrap/native.rs | 2 +- 21 | src/librustdoc/clean/cfg.rs | 1 + 22 | vendor/cc/src/lib.rs | 1 + 23 | vendor/object-0.29.0/src/elf.rs | 121 ++++++++++++++++-- 24 | 17 files changed, 165 insertions(+), 15 deletions(-) 25 | create mode 100644 compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs 26 | 27 | diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs 28 | index 019ec0758..118c68a92 100644 29 | --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs 30 | +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs 31 | @@ -123,6 +123,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option Architecture::PowerPc64, 33 | "riscv32" => Architecture::Riscv32, 34 | "riscv64" => Architecture::Riscv64, 35 | + "loongarch64" => Architecture::LoongArch64, 36 | "sparc64" => Architecture::Sparc64, 37 | "avr" => Architecture::Avr, 38 | "msp430" => Architecture::Msp430, 39 | @@ -172,6 +173,10 @@ pub(crate) fn create_object_file(sess: &Session) -> Option { 44 | + let e_flags = elf::EF_LARCH_ABI_DOUBLE_FLOAT; 45 | + e_flags 46 | + } 47 | Architecture::Riscv32 | Architecture::Riscv64 => { 48 | // Source: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/079772828bd10933d34121117a222b4cc0ee2200/riscv-elf.adoc 49 | let mut e_flags: u32 = 0x0; 50 | diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs 51 | index 9fe59a1d8..f30277014 100644 52 | --- a/compiler/rustc_llvm/build.rs 53 | +++ b/compiler/rustc_llvm/build.rs 54 | @@ -10,6 +10,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[ 55 | "aarch64", 56 | "amdgpu", 57 | "avr", 58 | + "loongarch", 59 | "m68k", 60 | "mips", 61 | "powerpc", 62 | diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp 63 | index 4761ce83f..f426b3231 100644 64 | --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp 65 | +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp 66 | @@ -136,6 +136,12 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) { 67 | #define SUBTARGET_RISCV 68 | #endif 69 | 70 | +#ifdef LLVM_COMPONENT_LOONGARCH 71 | +#define SUBTARGET_LOONGARCH SUBTARGET(LoongArch) 72 | +#else 73 | +#define SUBTARGET_LOONGARCH 74 | +#endif 75 | + 76 | #ifdef LLVM_COMPONENT_SPARC 77 | #define SUBTARGET_SPARC SUBTARGET(Sparc) 78 | #else 79 | @@ -161,6 +167,7 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) { 80 | SUBTARGET_SPARC \ 81 | SUBTARGET_HEXAGON \ 82 | SUBTARGET_RISCV \ 83 | + SUBTARGET_LOONGARCH \ 84 | 85 | #define SUBTARGET(x) \ 86 | namespace llvm { \ 87 | diff --git a/compiler/rustc_llvm/src/lib.rs b/compiler/rustc_llvm/src/lib.rs 88 | index 8542dcf5b..06351731b 100644 89 | --- a/compiler/rustc_llvm/src/lib.rs 90 | +++ b/compiler/rustc_llvm/src/lib.rs 91 | @@ -102,6 +102,14 @@ pub fn initialize_available_targets() { 92 | LLVMInitializeM68kAsmPrinter, 93 | LLVMInitializeM68kAsmParser 94 | ); 95 | + init_target!( 96 | + llvm_component = "loongarch", 97 | + LLVMInitializeLoongArchTargetInfo, 98 | + LLVMInitializeLoongArchTarget, 99 | + LLVMInitializeLoongArchTargetMC, 100 | + LLVMInitializeLoongArchAsmPrinter, 101 | + LLVMInitializeLoongArchAsmParser 102 | + ); 103 | init_target!( 104 | llvm_component = "mips", 105 | LLVMInitializeMipsTargetInfo, 106 | diff --git a/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs 107 | new file mode 100644 108 | index 000000000..2f9dd6ed9 109 | --- /dev/null 110 | +++ b/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs 111 | @@ -0,0 +1,19 @@ 112 | +use crate::spec::{CodeModel, Target, TargetOptions}; 113 | + 114 | +pub fn target() -> Target { 115 | + Target { 116 | + llvm_target: "loongarch64-unknown-linux-gnu".into(), 117 | + pointer_width: 64, 118 | + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), 119 | + arch: "loongarch64".into(), 120 | + options: TargetOptions { 121 | + code_model: Some(CodeModel::Medium), 122 | + cpu: "la464".into(), 123 | + features: "+f,+d".into(), 124 | + llvm_abiname: "lp64d".into(), 125 | + max_atomic_width: Some(64), 126 | + ..super::linux_gnu_base::opts() 127 | + } 128 | + } 129 | +} 130 | + 131 | diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs 132 | index 0d86a3032..8eb380439 100644 133 | --- a/compiler/rustc_target/src/spec/mod.rs 134 | +++ b/compiler/rustc_target/src/spec/mod.rs 135 | @@ -1029,6 +1029,7 @@ supported_targets! { 136 | ("mipsisa64r6-unknown-linux-gnuabi64", mipsisa64r6_unknown_linux_gnuabi64), 137 | ("mipsisa64r6el-unknown-linux-gnuabi64", mipsisa64r6el_unknown_linux_gnuabi64), 138 | ("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu), 139 | + ("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu), 140 | ("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu), 141 | ("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe), 142 | ("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl), 143 | diff --git a/library/std/src/env.rs b/library/std/src/env.rs 144 | index 183f9ab3b..3014fe6e2 100644 145 | --- a/library/std/src/env.rs 146 | +++ b/library/std/src/env.rs 147 | @@ -895,6 +895,7 @@ pub mod consts { 148 | /// - x86_64 149 | /// - arm 150 | /// - aarch64 151 | + /// - loongarch64 152 | /// - m68k 153 | /// - mips 154 | /// - mips64 155 | diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs 156 | index f46028c3a..c76fb4a47 100644 157 | --- a/library/std/src/os/linux/raw.rs 158 | +++ b/library/std/src/os/linux/raw.rs 159 | @@ -235,7 +235,8 @@ mod arch { 160 | target_arch = "s390x", 161 | target_arch = "sparc64", 162 | target_arch = "riscv64", 163 | - target_arch = "riscv32" 164 | + target_arch = "riscv32", 165 | + target_arch = "loongarch64" 166 | ))] 167 | mod arch { 168 | #[stable(feature = "raw_ext", since = "1.1.0")] 169 | diff --git a/library/std/src/personality/gcc.rs b/library/std/src/personality/gcc.rs 170 | index 41c0fe725..6533c9c3d 100644 171 | --- a/library/std/src/personality/gcc.rs 172 | +++ b/library/std/src/personality/gcc.rs 173 | @@ -77,6 +77,9 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 174 | #[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] 175 | const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 176 | 177 | +#[cfg(target_arch = "loongarch64")] 178 | +const UNWIND_DATA_REG: (i32, i32) = (4, 5); // A0, A1 179 | + 180 | // The following code is based on GCC's C and C++ personality routines. For reference, see: 181 | // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc 182 | // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c 183 | diff --git a/library/std/src/sys/common/alloc.rs b/library/std/src/sys/common/alloc.rs 184 | index 403a5e627..a5fcbdf39 100644 185 | --- a/library/std/src/sys/common/alloc.rs 186 | +++ b/library/std/src/sys/common/alloc.rs 187 | @@ -22,6 +22,7 @@ pub const MIN_ALIGN: usize = 8; 188 | #[cfg(any( 189 | target_arch = "x86_64", 190 | target_arch = "aarch64", 191 | + target_arch = "loongarch64", 192 | target_arch = "mips64", 193 | target_arch = "s390x", 194 | target_arch = "sparc64", 195 | diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs 196 | index eeeed3afc..2ef405f54 100644 197 | --- a/library/unwind/src/libunwind.rs 198 | +++ b/library/unwind/src/libunwind.rs 199 | @@ -51,6 +51,9 @@ pub const unwinder_private_data_size: usize = 5; 200 | #[cfg(target_arch = "m68k")] 201 | pub const unwinder_private_data_size: usize = 2; 202 | 203 | +#[cfg(target_arch = "loongarch64")] 204 | +pub const unwinder_private_data_size: usize = 2; 205 | + 206 | #[cfg(target_arch = "mips")] 207 | pub const unwinder_private_data_size: usize = 2; 208 | 209 | diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py 210 | index 013d1ab52..cd5948439 100644 211 | --- a/src/bootstrap/bootstrap.py 212 | +++ b/src/bootstrap/bootstrap.py 213 | @@ -304,6 +304,7 @@ def default_build_triple(verbose): 214 | 'i486': 'i686', 215 | 'i686': 'i686', 216 | 'i786': 'i686', 217 | + 'loongarch64': 'loongarch64', 218 | 'm68k': 'm68k', 219 | 'powerpc': 'powerpc', 220 | 'powerpc64': 'powerpc64', 221 | diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs 222 | index 950f3b151..72252c7c6 100644 223 | --- a/src/bootstrap/lib.rs 224 | +++ b/src/bootstrap/lib.rs 225 | @@ -127,7 +127,7 @@ const EXTRA_CHECK_CFGS: &[(Option, &'static str, Option<&[&'static str]>)] 226 | /* Extra values not defined in the built-in targets yet, but used in std */ 227 | (Some(Mode::Std), "target_env", Some(&["libnx"])), 228 | // (Some(Mode::Std), "target_os", Some(&[])), 229 | - (Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa"])), 230 | + (Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa", "loongarch64"])), 231 | /* Extra names used by dependencies */ 232 | // FIXME: Used by serde_json, but we should not be triggering on external dependencies. 233 | (Some(Mode::Rustc), "no_btreemap_remove_entry", None), 234 | diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs 235 | index 5987b641b..98b6f3150 100644 236 | --- a/src/bootstrap/native.rs 237 | +++ b/src/bootstrap/native.rs 238 | @@ -301,7 +301,7 @@ impl Step for Llvm { 239 | let llvm_targets = match &builder.config.llvm_targets { 240 | Some(s) => s, 241 | None => { 242 | - "AArch64;ARM;BPF;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\ 243 | + "AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;\ 244 | Sparc;SystemZ;WebAssembly;X86" 245 | } 246 | }; 247 | diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs 248 | index dd58a5b51..68ff0df8e 100644 249 | --- a/src/librustdoc/clean/cfg.rs 250 | +++ b/src/librustdoc/clean/cfg.rs 251 | @@ -517,6 +517,7 @@ impl<'a> fmt::Display for Display<'a> { 252 | "aarch64" => "AArch64", 253 | "arm" => "ARM", 254 | "asmjs" => "JavaScript", 255 | + "loongarch64" => "LoongArch64", 256 | "m68k" => "M68k", 257 | "mips" => "MIPS", 258 | "mips64" => "MIPS-64", 259 | diff --git a/vendor/cc/src/lib.rs b/vendor/cc/src/lib.rs 260 | index 1ebd2cc7a..85df9dbf1 100644 261 | --- a/vendor/cc/src/lib.rs 262 | +++ b/vendor/cc/src/lib.rs 263 | @@ -2774,6 +2774,7 @@ impl Build { 264 | ]), // explicit None if not found, so caller knows to fall back 265 | "i686-unknown-linux-musl" => Some("musl"), 266 | "i686-unknown-netbsd" => Some("i486--netbsdelf"), 267 | + "loongarch64-unknown-linux-gnu" => Some("loongarch64-linux-gnu"), 268 | "mips-unknown-linux-gnu" => Some("mips-linux-gnu"), 269 | "mips-unknown-linux-musl" => Some("mips-linux-musl"), 270 | "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"), 271 | diff --git a/vendor/object-0.29.0/src/elf.rs b/vendor/object-0.29.0/src/elf.rs 272 | index 9f6577269..38b058916 100644 273 | --- a/vendor/object-0.29.0/src/elf.rs 274 | +++ b/vendor/object-0.29.0/src/elf.rs 275 | @@ -6251,18 +6251,17 @@ pub const R_NDS32_TLS_TPOFF: u32 = 102; 276 | pub const R_NDS32_TLS_DESC: u32 = 119; 277 | 278 | // LoongArch values `FileHeader*::e_flags`. 279 | -/// Uses 64-bit GPRs and the stack for parameter passing 280 | -pub const EF_LARCH_ABI_LP64S: u32 = 0x1; 281 | -/// Uses 64-bit GPRs, 32-bit FPRs and the stack for parameter passing 282 | -pub const EF_LARCH_ABI_LP64F: u32 = 0x2; 283 | -/// Uses 64-bit GPRs, 64-bit FPRs and the stack for parameter passing 284 | -pub const EF_LARCH_ABI_LP64D: u32 = 0x3; 285 | -/// Uses 32-bit GPRs and the stack for parameter passing 286 | -pub const EF_LARCH_ABI_ILP32S: u32 = 0x5; 287 | -/// Uses 32-bit GPRs, 32-bit FPRs and the stack for parameter passing 288 | -pub const EF_LARCH_ABI_ILP32F: u32 = 0x6; 289 | -/// Uses 32-bit GPRs, 64-bit FPRs and the stack for parameter passing 290 | -pub const EF_LARCH_ABI_ILP32D: u32 = 0x7; 291 | +/// Additional properties of the base ABI type, including the FP calling 292 | +/// convention. 293 | +pub const EF_LARCH_ABI_MODIFIER_MASK: u32 = 0x7; 294 | +/// Uses GPRs and the stack for parameter passing 295 | +pub const EF_LARCH_ABI_SOFT_FLOAT: u32 = 0x1; 296 | +/// Uses GPRs, 32-bit FPRs and the stack for parameter passing 297 | +pub const EF_LARCH_ABI_SINGLE_FLOAT: u32 = 0x2; 298 | +/// Uses GPRs, 64-bit FPRs and the stack for parameter passing 299 | +pub const EF_LARCH_ABI_DOUBLE_FLOAT: u32 = 0x3; 300 | +/// Uses relocation types directly writing to immediate slots 301 | +pub const EF_LARCH_OBJABI_V1: u32 = 0x40; 302 | 303 | // LoongArch values `Rel*::r_type`. 304 | /// No reloc 305 | @@ -6372,6 +6371,104 @@ pub const R_LARCH_SUB64: u32 = 56; 306 | pub const R_LARCH_GNU_VTINHERIT: u32 = 57; 307 | /// GNU C++ vtable member usage 308 | pub const R_LARCH_GNU_VTENTRY: u32 = 58; 309 | +/// 18-bit PC-relative jump offset with two trailing zeros 310 | +pub const R_LARCH_B16: u32 = 64; 311 | +/// 23-bit PC-relative jump offset with two trailing zeros 312 | +pub const R_LARCH_B21: u32 = 65; 313 | +/// 28-bit PC-relative jump offset with two trailing zeros 314 | +pub const R_LARCH_B26: u32 = 66; 315 | +/// 12..=31 bits of 32/64-bit absolute address 316 | +pub const R_LARCH_ABS_HI20: u32 = 67; 317 | +/// 0..=11 bits of 32/64-bit absolute address 318 | +pub const R_LARCH_ABS_LO12: u32 = 68; 319 | +/// 32..=51 bits of 64-bit absolute address 320 | +pub const R_LARCH_ABS64_LO20: u32 = 69; 321 | +/// 52..=63 bits of 64-bit absolute address 322 | +pub const R_LARCH_ABS64_HI12: u32 = 70; 323 | +/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to 324 | +/// `(S + A + 0x800) & 0xfffff000`, with 12 trailing zeros removed. 325 | +/// 326 | +/// We define the *PC relative anchor* for `S + A` as `PC + offs` (`offs` 327 | +/// is sign-extended to VA bits). 328 | +pub const R_LARCH_PCALA_HI20: u32 = 71; 329 | +/// Same as R_LARCH_ABS_LO12. 0..=11 bits of the 32/64-bit offset from the 330 | +/// [PC relative anchor][R_LARCH_PCALA_HI20]. 331 | +pub const R_LARCH_PCALA_LO12: u32 = 72; 332 | +/// 32..=51 bits of the 64-bit offset from the 333 | +/// [PC relative anchor][R_LARCH_PCALA_HI20]. 334 | +pub const R_LARCH_PCALA64_LO20: u32 = 73; 335 | +/// 52..=63 bits of the 64-bit offset from the 336 | +/// [PC relative anchor][R_LARCH_PCALA_HI20]. 337 | +pub const R_LARCH_PCALA64_HI12: u32 = 74; 338 | +/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to 339 | +/// `(GP + G + 0x800) & 0xfffff000`, with 12 trailing zeros removed. 340 | +/// 341 | +/// We define the *PC relative anchor* for the GOT entry at `GP + G` as 342 | +/// `PC + offs` (`offs` is sign-extended to VA bits). 343 | +pub const R_LARCH_GOT_PC_HI20: u32 = 75; 344 | +/// 0..=11 bits of the 32/64-bit offset from the 345 | +/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry. 346 | +pub const R_LARCH_GOT_PC_LO12: u32 = 76; 347 | +/// 32..=51 bits of the 64-bit offset from the 348 | +/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry. 349 | +pub const R_LARCH_GOT64_PC_LO20: u32 = 77; 350 | +/// 52..=63 bits of the 64-bit offset from the 351 | +/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry. 352 | +pub const R_LARCH_GOT64_PC_HI12: u32 = 78; 353 | +/// 12..=31 bits of 32/64-bit GOT entry absolute address 354 | +pub const R_LARCH_GOT_HI20: u32 = 79; 355 | +/// 0..=11 bits of 32/64-bit GOT entry absolute address 356 | +pub const R_LARCH_GOT_LO12: u32 = 80; 357 | +/// 32..=51 bits of 64-bit GOT entry absolute address 358 | +pub const R_LARCH_GOT64_LO20: u32 = 81; 359 | +/// 52..=63 bits of 64-bit GOT entry absolute address 360 | +pub const R_LARCH_GOT64_HI12: u32 = 82; 361 | +/// 12..=31 bits of TLS LE 32/64-bit offset from thread pointer 362 | +pub const R_LARCH_TLS_LE_HI20: u32 = 83; 363 | +/// 0..=11 bits of TLS LE 32/64-bit offset from thread pointer 364 | +pub const R_LARCH_TLS_LE_LO12: u32 = 84; 365 | +/// 32..=51 bits of TLS LE 64-bit offset from thread pointer 366 | +pub const R_LARCH_TLS_LE64_LO20: u32 = 85; 367 | +/// 52..=63 bits of TLS LE 64-bit offset from thread pointer 368 | +pub const R_LARCH_TLS_LE64_HI12: u32 = 86; 369 | +/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to 370 | +/// `(GP + IE + 0x800) & 0xfffff000`, with 12 trailing zeros removed. 371 | +/// 372 | +/// We define the *PC relative anchor* for the TLS IE GOT entry at 373 | +/// `GP + IE` as `PC + offs` (`offs` is sign-extended to VA bits). 374 | +pub const R_LARCH_TLS_IE_PC_HI20: u32 = 87; 375 | +/// 0..=12 bits of the 32/64-bit offset from the 376 | +/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry. 377 | +pub const R_LARCH_TLS_IE_PC_LO12: u32 = 88; 378 | +/// 32..=51 bits of the 64-bit offset from the 379 | +/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry. 380 | +pub const R_LARCH_TLS_IE64_PC_LO20: u32 = 89; 381 | +/// 52..=63 bits of the 64-bit offset from the 382 | +/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry. 383 | +pub const R_LARCH_TLS_IE64_PC_HI12: u32 = 90; 384 | +/// 12..=31 bits of TLS IE GOT entry 32/64-bit absolute address 385 | +pub const R_LARCH_TLS_IE_HI20: u32 = 91; 386 | +/// 0..=11 bits of TLS IE GOT entry 32/64-bit absolute address 387 | +pub const R_LARCH_TLS_IE_LO12: u32 = 92; 388 | +/// 32..=51 bits of TLS IE GOT entry 64-bit absolute address 389 | +pub const R_LARCH_TLS_IE64_LO20: u32 = 93; 390 | +/// 51..=63 bits of TLS IE GOT entry 64-bit absolute address 391 | +pub const R_LARCH_TLS_IE64_HI12: u32 = 94; 392 | +/// 12..=31 bits of the offset from `PC` to `GP + GD + 0x800`, where 393 | +/// `GP + GD` is a TLS LD GOT entry 394 | +pub const R_LARCH_TLS_LD_PC_HI20: u32 = 95; 395 | +/// 12..=31 bits of TLS LD GOT entry 32/64-bit absolute address 396 | +pub const R_LARCH_TLS_LD_HI20: u32 = 96; 397 | +/// 12..=31 bits of the 32/64-bit PC-relative offset to the PC-relative 398 | +/// anchor for the TLE GD GOT entry. 399 | +pub const R_LARCH_TLS_GD_PC_HI20: u32 = 97; 400 | +/// 12..=31 bits of TLS GD GOT entry 32/64-bit absolute address 401 | +pub const R_LARCH_TLS_GD_HI20: u32 = 98; 402 | +/// 32-bit PC relative 403 | +pub const R_LARCH_32_PCREL: u32 = 99; 404 | +/// Paired with a normal relocation at the same address to indicate the 405 | +/// insturction can be relaxed 406 | +pub const R_LARCH_RELAX: u32 = 100; 407 | 408 | unsafe_impl_endian_pod!( 409 | FileHeader32, 410 | -- 411 | 2.31.1 412 | 413 | -------------------------------------------------------------------------------- /patches/0001-rustc-1.69.0-vendor-nix-add-loongarch64-support.patch: -------------------------------------------------------------------------------- 1 | From 6c3d3a3319a0156b5f5ba8843cf92df8274ca103 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Fri, 21 Apr 2023 17:38:52 +0000 4 | Subject: [PATCH] rustc 1.69.0 vendor nix add loongarch64 support. 5 | 6 | --- 7 | vendor/nix/src/sys/ioctl/linux.rs | 1 + 8 | 1 file changed, 1 insertion(+) 9 | 10 | diff --git a/vendor/nix/src/sys/ioctl/linux.rs b/vendor/nix/src/sys/ioctl/linux.rs 11 | index 0c0a20905..214d9e8c6 100644 12 | --- a/vendor/nix/src/sys/ioctl/linux.rs 13 | +++ b/vendor/nix/src/sys/ioctl/linux.rs 14 | @@ -41,6 +41,7 @@ mod consts { 15 | target_arch = "s390x", 16 | target_arch = "x86_64", 17 | target_arch = "aarch64", 18 | + target_arch = "loongarch64", 19 | target_arch = "riscv32", 20 | target_arch = "riscv64" 21 | ))] 22 | -- 23 | 2.31.1 24 | 25 | -------------------------------------------------------------------------------- /patches/0001_xpcom_add_loongarch64_support.patch: -------------------------------------------------------------------------------- 1 | Written by: Wu Jiahuan 2 | 3 | diff -r b1b50f07c34b xpcom/reflect/xptcall/md/unix/moz.build 4 | --- a/xpcom/reflect/xptcall/md/unix/moz.build Thu Apr 06 05:27:08 2023 +0000 5 | +++ b/xpcom/reflect/xptcall/md/unix/moz.build Tue Apr 11 19:38:08 2023 +0800 6 | @@ -271,6 +271,14 @@ 7 | "xptcstubs_riscv64.cpp", 8 | ] 9 | 10 | +if CONFIG["OS_ARCH"] == "Linux" and CONFIG["CPU_ARCH"] == "loongarch64": 11 | + SOURCES += [ 12 | + "xptcinvoke_asm_loongarch64.S", 13 | + "xptcinvoke_loongarch64.cpp", 14 | + "xptcstubs_asm_loongarch64.S", 15 | + "xptcstubs_loongarch64.cpp", 16 | + ] 17 | + 18 | FINAL_LIBRARY = "xul" 19 | 20 | LOCAL_INCLUDES += [ 21 | diff -r b1b50f07c34b xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_loongarch64.S 22 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23 | +++ b/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_loongarch64.S Tue Apr 11 19:38:08 2023 +0800 24 | @@ -0,0 +1,92 @@ 25 | +/* This Source Code Form subject to the terms of Mozilla Public 26 | + * License, v. 2.0 If a copy of the MPL was not distributed with 27 | + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. 28 | + */ 29 | + 30 | + .set NGPREGS, 8 31 | + .set NFPREGS, 8 32 | + 33 | + .text 34 | + .globl _NS_InvokeByIndex 35 | + .type _NS_InvokeByIndex, @function 36 | +/* 37 | + * _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, 38 | + * uint32_t paramCount, nsXPTCVariant* params) 39 | + */ 40 | +_NS_InvokeByIndex: 41 | + .cfi_startproc 42 | + addi.d $sp, $sp, -32 43 | + .cfi_def_cfa_offset 32 44 | + st.d $s0, $sp, 16 45 | + .cfi_offset 23, -16 46 | + st.d $s1, $sp, 8 47 | + .cfi_offset 24, -24 48 | + st.d $s2, $sp, 0 49 | + .cfi_offset 25, -32 50 | + st.d $ra, $sp, 24 51 | + .cfi_offset 1, -8 52 | + 53 | + move $s2, $a0 54 | + move $s1, $a1 55 | + move $s0, $sp 56 | + .cfi_def_cfa_register 23 57 | + 58 | + /* 16-bytes alignment */ 59 | + addi.d $a0, $a2, 1 60 | + li.d $t4, 0xfffffffffffffffe 61 | + and $a0, $a0, $t4 62 | + slli.d $a0, $a0, 3 63 | + sub.d $sp, $sp, $a0 64 | + move $a4, $sp 65 | + 66 | + addi.d $sp, $sp, -8*(NFPREGS+NGPREGS) 67 | + move $a0, $sp 68 | + addi.d $a1, $sp, 8*NGPREGS 69 | + 70 | + bl invoke_copy_to_stack 71 | + 72 | + /* 1st argument is this */ 73 | + move $a0, $s2 74 | + 75 | + ld.d $a1, $sp, 8 76 | + ld.d $a2, $sp, 16 77 | + ld.d $a3, $sp, 24 78 | + ld.d $a4, $sp, 32 79 | + ld.d $a5, $sp, 40 80 | + ld.d $a6, $sp, 48 81 | + ld.d $a7, $sp, 56 82 | + 83 | + fld.d $fa0, $sp, 64 84 | + fld.d $fa1, $sp, 72 85 | + fld.d $fa2, $sp, 80 86 | + fld.d $fa3, $sp, 88 87 | + fld.d $fa4, $sp, 96 88 | + fld.d $fa5, $sp, 104 89 | + fld.d $fa6, $sp, 112 90 | + fld.d $fa7, $sp, 120 91 | + 92 | + addi.d $sp, $sp, 8*(NGPREGS+NFPREGS) 93 | + 94 | + ld.d $s2, $s2, 0 95 | + slli.w $s1, $s1, 3 96 | + add.d $s2, $s2, $s1 97 | + ld.d $t3, $s2, 0 98 | + jirl $ra, $t3, 0 99 | + 100 | + move $sp, $s0 101 | + .cfi_def_cfa_register 3 102 | + ld.d $s0, $sp, 16 103 | + .cfi_restore 23 104 | + ld.d $s1, $sp, 8 105 | + .cfi_restore 24 106 | + ld.d $s2, $sp, 0 107 | + .cfi_restore 25 108 | + ld.d $ra, $sp, 24 109 | + .cfi_restore 1 110 | + addi.d $sp, $sp, 32 111 | + .cfi_def_cfa_offset -32 112 | + jirl $zero, $ra, 0 113 | + .cfi_endproc 114 | + .size _NS_InvokeByIndex, .-_NS_InvokeByIndex 115 | + .section .note.GNU-stack, "", @progbits 116 | + 117 | diff -r b1b50f07c34b xpcom/reflect/xptcall/md/unix/xptcinvoke_loongarch64.cpp 118 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 119 | +++ b/xpcom/reflect/xptcall/md/unix/xptcinvoke_loongarch64.cpp Tue Apr 11 19:38:08 2023 +0800 120 | @@ -0,0 +1,100 @@ 121 | +/* This Source Code Form is subject to the terms of the Mozilla Public 122 | + * License, v. 2.0. If a copy of the MPL was not distributed with this 123 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 124 | + 125 | +// Platform specific code to invoke XPCOM methods on native objects 126 | + 127 | +#include "xptcprivate.h" 128 | + 129 | +extern "C" void invoke_copy_to_stack(uint64_t* gpregs, double* fpregs, 130 | + uint32_t paramCount, nsXPTCVariant* s, 131 | + uint64_t* d) { 132 | + static const uint32_t GPR_COUNT = 8; 133 | + static const uint32_t FPR_COUNT = 8; 134 | + 135 | + uint32_t nr_gpr = 1; // skip one GPR register for "this" 136 | + uint32_t nr_fpr = 0; 137 | + uint64_t value = 0; 138 | + 139 | + for (uint32_t i = 0; i < paramCount; i++, s++) { 140 | + if (s->IsIndirect()) { 141 | + value = (uint64_t)&s->val; 142 | + } else { 143 | + switch (s->type) { 144 | + case nsXPTType::T_FLOAT: 145 | + break; 146 | + case nsXPTType::T_DOUBLE: 147 | + break; 148 | + case nsXPTType::T_I8: 149 | + value = s->val.i8; 150 | + break; 151 | + case nsXPTType::T_I16: 152 | + value = s->val.i16; 153 | + break; 154 | + case nsXPTType::T_I32: 155 | + value = s->val.i32; 156 | + break; 157 | + case nsXPTType::T_I64: 158 | + value = s->val.i64; 159 | + break; 160 | + case nsXPTType::T_U8: 161 | + value = s->val.u8; 162 | + break; 163 | + case nsXPTType::T_U16: 164 | + value = s->val.u16; 165 | + break; 166 | + case nsXPTType::T_U32: 167 | + value = s->val.u32; 168 | + break; 169 | + case nsXPTType::T_U64: 170 | + value = s->val.u64; 171 | + break; 172 | + case nsXPTType::T_BOOL: 173 | + value = s->val.b; 174 | + break; 175 | + case nsXPTType::T_CHAR: 176 | + value = s->val.c; 177 | + break; 178 | + case nsXPTType::T_WCHAR: 179 | + value = s->val.wc; 180 | + break; 181 | + default: 182 | + value = (uint64_t)s->val.p; 183 | + break; 184 | + } 185 | + } 186 | + 187 | + if (!s->IsIndirect() && s->type == nsXPTType::T_DOUBLE) { 188 | + if (nr_fpr < FPR_COUNT) { 189 | + fpregs[nr_fpr++] = s->val.d; 190 | + } else if (nr_gpr < GPR_COUNT) { 191 | + memcpy(&gpregs[nr_gpr++], &(s->val.d), sizeof(s->val.d)); 192 | + } else { 193 | + memcpy(d++, &(s->val.d), sizeof(s->val.d)); 194 | + } 195 | + } else if (!s->IsIndirect() && s->type == nsXPTType::T_FLOAT) { 196 | + if (nr_fpr < FPR_COUNT) { 197 | + memcpy(&fpregs[nr_fpr++], &(s->val.f), sizeof(s->val.f)); 198 | + } else if (nr_gpr < GPR_COUNT) { 199 | + memcpy(&gpregs[nr_gpr++], &(s->val.f), sizeof(s->val.f)); 200 | + } else { 201 | + memcpy(d++, &(s->val.f), sizeof(s->val.f)); 202 | + } 203 | + } else { 204 | + if (nr_gpr < GPR_COUNT) { 205 | + gpregs[nr_gpr++] = value; 206 | + } else { 207 | + *d++ = value; 208 | + } 209 | + } 210 | + } 211 | +} 212 | + 213 | +extern "C" nsresult _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, 214 | + uint32_t paramCount, 215 | + nsXPTCVariant* params); 216 | +EXPORT_XPCOM_API(nsresult) 217 | +NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, uint32_t paramCount, 218 | + nsXPTCVariant* params) { 219 | + return _NS_InvokeByIndex(that, methodIndex, paramCount, params); 220 | +} 221 | diff -r b1b50f07c34b xpcom/reflect/xptcall/md/unix/xptcstubs_asm_loongarch64.S 222 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 223 | +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_loongarch64.S Tue Apr 11 19:38:08 2023 +0800 224 | @@ -0,0 +1,52 @@ 225 | +# License, v. 2.0. If a copy of the MPL was not distributed with this 226 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 227 | + 228 | + .set NGPRGES, 8 229 | + .set NFPREGS, 8 230 | + 231 | + .text 232 | + .globl SharedStub 233 | + .hidden SharedStub 234 | + .type SharedStub,@function 235 | + 236 | +SharedStub: 237 | + .cfi_startproc 238 | + move $t0, $sp 239 | + addi.d $sp, $sp, -8*(NGPRGES+NFPREGS)-16 240 | + .cfi_def_cfa_offset 8*(NGPRGES+NFPREGS)+16 241 | + st.d $a0, $sp, 0 242 | + st.d $a1, $sp, 8 243 | + st.d $a2, $sp, 16 244 | + st.d $a3, $sp, 24 245 | + st.d $a4, $sp, 32 246 | + st.d $a5, $sp, 40 247 | + st.d $a6, $sp, 48 248 | + st.d $a7, $sp, 56 249 | + fst.d $fa0, $sp, 64 250 | + fst.d $fa1, $sp, 72 251 | + fst.d $fa2, $sp, 80 252 | + fst.d $fa3, $sp, 88 253 | + fst.d $fa4, $sp, 96 254 | + fst.d $fa5, $sp, 104 255 | + fst.d $fa6, $sp, 112 256 | + fst.d $fa7, $sp, 120 257 | + st.d $ra, $sp, 136 258 | + .cfi_offset 1, 136 259 | + 260 | + /* methodIndex is passed from stub */ 261 | + move $a1, $t6 262 | + move $a2, $t0 263 | + move $a3, $sp 264 | + addi.d $a4, $sp, 8*NGPRGES 265 | + 266 | + bl PrepareAndDispatch 267 | + 268 | + ld.d $ra, $sp, 136 269 | + .cfi_restore 1 270 | + addi.d $sp, $sp, 8*(NGPRGES+NFPREGS)+16 271 | + .cfi_def_cfa_offset -8*(NGPRGES+NFPREGS)-16 272 | + jirl $zero, $ra, 0 273 | + .cfi_endproc 274 | + 275 | + .size SharedStub, .-SharedStub 276 | + .section .note.GNU-stack, "", @progbits 277 | diff -r b1b50f07c34b xpcom/reflect/xptcall/md/unix/xptcstubs_loongarch64.cpp 278 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 279 | +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_loongarch64.cpp Tue Apr 11 19:38:08 2023 +0800 280 | @@ -0,0 +1,159 @@ 281 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 282 | +/* This Source Code Form is subject to the terms of the Mozilla Public 283 | + * License, V. 2.0. If a copy of the MPL was not distributed with this 284 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 285 | + 286 | +#include "xptcprivate.h" 287 | + 288 | +extern "C" nsresult ATTRIBUTE_USED PrepareAndDispatch(nsXPTCStubBase* self, 289 | + uint32_t methodIndex, 290 | + uint64_t* args, 291 | + uint64_t* gpregs, 292 | + double* fpregs) { 293 | + static const uint32_t GPR_COUNT = 8; 294 | + static const uint32_t FPR_COUNT = 8; 295 | + nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; 296 | + const nsXPTMethodInfo* info; 297 | + 298 | + self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); 299 | + 300 | + uint32_t paramCount = info->GetParamCount(); 301 | + const uint8_t indexOfJSContext = info->IndexOfJSContext(); 302 | + 303 | + uint64_t* ap = args; 304 | + uint32_t nr_gpr = 1; // skip the arg which is 'self' 305 | + uint32_t nr_fpr = 0; 306 | + uint64_t value; 307 | + 308 | + for (uint32_t i = 0; i < paramCount; i++) { 309 | + const nsXPTParamInfo& param = info->GetParam(i); 310 | + const nsXPTType& type = param.GetType(); 311 | + nsXPTCMiniVariant* dp = ¶mBuffer[i]; 312 | + 313 | + if (i == indexOfJSContext) { 314 | + if (nr_gpr < GPR_COUNT) 315 | + nr_gpr++; 316 | + else 317 | + ap++; 318 | + } 319 | + 320 | + if (!param.IsOut() && type == nsXPTType::T_DOUBLE) { 321 | + if (nr_fpr < FPR_COUNT) { 322 | + dp->val.d = fpregs[nr_fpr++]; 323 | + } else if (nr_gpr < GPR_COUNT) { 324 | + memcpy(&dp->val.d, &gpregs[nr_gpr++], sizeof(dp->val.d)); 325 | + } else { 326 | + memcpy(&dp->val.d, ap++, sizeof(dp->val.d)); 327 | + } 328 | + continue; 329 | + } 330 | + 331 | + if (!param.IsOut() && type == nsXPTType::T_FLOAT) { 332 | + if (nr_fpr < FPR_COUNT) { 333 | + memcpy(&dp->val.f, &fpregs[nr_fpr++], sizeof(dp->val.f)); 334 | + } else if (nr_gpr < GPR_COUNT) { 335 | + memcpy(&dp->val.f, &gpregs[nr_gpr++], sizeof(dp->val.f)); 336 | + } else { 337 | + memcpy(&dp->val.f, ap++, sizeof(dp->val.f)); 338 | + } 339 | + continue; 340 | + } 341 | + 342 | + if (nr_gpr < GPR_COUNT) { 343 | + value = gpregs[nr_gpr++]; 344 | + } else { 345 | + value = *ap++; 346 | + } 347 | + 348 | + if (param.IsOut() || !type.IsArithmetic()) { 349 | + dp->val.p = (void*)value; 350 | + continue; 351 | + } 352 | + 353 | + switch (type) { 354 | + case nsXPTType::T_I8: 355 | + dp->val.i8 = (int8_t)value; 356 | + break; 357 | + case nsXPTType::T_I16: 358 | + dp->val.i16 = (int16_t)value; 359 | + break; 360 | + case nsXPTType::T_I32: 361 | + dp->val.i32 = (int32_t)value; 362 | + break; 363 | + case nsXPTType::T_I64: 364 | + dp->val.i64 = (int64_t)value; 365 | + break; 366 | + case nsXPTType::T_U8: 367 | + dp->val.u8 = (uint8_t)value; 368 | + break; 369 | + case nsXPTType::T_U16: 370 | + dp->val.u16 = (uint16_t)value; 371 | + break; 372 | + case nsXPTType::T_U32: 373 | + dp->val.u32 = (uint32_t)value; 374 | + break; 375 | + case nsXPTType::T_U64: 376 | + dp->val.u64 = (uint64_t)value; 377 | + break; 378 | + case nsXPTType::T_BOOL: 379 | + dp->val.b = (bool)(uint8_t)value; 380 | + break; 381 | + case nsXPTType::T_CHAR: 382 | + dp->val.c = (char)value; 383 | + break; 384 | + case nsXPTType::T_WCHAR: 385 | + dp->val.wc = (wchar_t)value; 386 | + break; 387 | + default: 388 | + NS_ERROR("bad type"); 389 | + break; 390 | + } 391 | + } 392 | + 393 | + nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info, 394 | + paramBuffer); 395 | + return result; 396 | +} 397 | + 398 | +// Load $t6 with the constant 'n' and branch to SharedStub(). 399 | +// clang-format off 400 | +#define STUB_ENTRY(n) \ 401 | + __asm__( \ 402 | + ".text\n\t" \ 403 | + ".if "#n" < 10 \n\t" \ 404 | + ".globl _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ 405 | + ".hidden _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ 406 | + ".type _ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n" \ 407 | + "_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t" \ 408 | + ".elseif "#n" < 100 \n\t" \ 409 | + ".globl _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ 410 | + ".hidden _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ 411 | + ".type _ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n" \ 412 | + "_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t" \ 413 | + ".elseif "#n" < 1000 \n\t" \ 414 | + ".globl _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ 415 | + ".hidden _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ 416 | + ".type _ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n" \ 417 | + "_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t" \ 418 | + ".else \n\t" \ 419 | + ".err \"stub number "#n" >= 1000 not yet supported\"\n" \ 420 | + ".endif \n\t" \ 421 | + "li.d $t6, "#n" \n\t" \ 422 | + "b SharedStub \n" \ 423 | + ".if "#n" < 10 \n\t" \ 424 | + ".size _ZN14nsXPTCStubBase5Stub"#n"Ev,.-_ZN14nsXPTCStubBase5Stub"#n"Ev\n\t" \ 425 | + ".elseif "#n" < 100 \n\t" \ 426 | + ".size _ZN14nsXPTCStubBase6Stub"#n"Ev,.-_ZN14nsXPTCStubBase6Stub"#n"Ev\n\t" \ 427 | + ".else \n\t" \ 428 | + ".size _ZN14nsXPTCStubBase7Stub"#n"Ev,.-_ZN14nsXPTCStubBase7Stub"#n"Ev\n\t" \ 429 | + ".endif" \ 430 | +); 431 | +// clang-format on 432 | + 433 | +#define SENTINEL_ENTRY(n) \ 434 | + nsresult nsXPTCStubBase::Sentinel##n() { \ 435 | + NS_ERROR("nsXPTCStubBase::Sentinel called"); \ 436 | + return NS_ERROR_NOT_IMPLEMENTED; \ 437 | + } 438 | + 439 | +#include "xptcstubsdef.inc" 440 | -------------------------------------------------------------------------------- /patches/cmake-3.22.3-add-loongarch64-to-checktypesize.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp cmake-3.22.3.orig/Modules/CheckTypeSize.c.in cmake-3.22.3/Modules/CheckTypeSize.c.in 2 | --- cmake-3.22.3.orig/Modules/CheckTypeSize.c.in 2022-03-04 17:06:35.000000000 +0000 3 | +++ cmake-3.22.3/Modules/CheckTypeSize.c.in 2022-03-18 08:17:38.518281758 +0000 4 | @@ -13,6 +13,8 @@ 5 | # define KEY '_','_','P','P','C','_','_' 6 | #elif defined(__ppc__) 7 | # define KEY '_','_','p','p','c','_','_' 8 | +#elif defined(__loongarch_lp64) 9 | +# define KEY '_','_','l','o','o','n','g','a','r','c','h','_','l','p','6','4' 10 | #elif defined(__aarch64__) 11 | # define KEY '_','_','a','a','r','c','h','6','4','_','_' 12 | #elif defined(__ARM_ARCH_7A__) 13 | -------------------------------------------------------------------------------- /patches/ctags-5.8-fix_form_fedora.patch: -------------------------------------------------------------------------------- 1 | diff -up ctags-5.7/Makefile.in.destdir ctags-5.7/Makefile.in 2 | --- ctags-5.7/Makefile.in.destdir 2006-10-12 05:26:40.000000000 +0200 3 | +++ ctags-5.7/Makefile.in 2008-02-15 17:10:23.000000000 +0100 4 | @@ -59,7 +59,7 @@ include $(srcdir)/source.mak 5 | 6 | VPATH = $(srcdir) 7 | 8 | -INSTALL = cp 9 | +INSTALL = cp -p 10 | INSTALL_PROG = $(INSTALL) 11 | INSTALL_DATA = $(INSTALL) 12 | 13 | @@ -138,7 +141,8 @@ install-ebin: $(DEST_ETAGS) 14 | install-lib: $(DEST_READ_LIB) $(DEST_READ_INC) 15 | 16 | $(DEST_CTAGS): $(CTAGS_EXEC) $(bindir) FORCE 17 | - $(INSTALL_PROG) $(CTAGS_EXEC) $@ && chmod 755 $@ 18 | + $(srcdir)/mkinstalldirs $(DESTDIR)$(bindir) 19 | + $(INSTALL_PROG) $(CTAGS_EXEC) $(DESTDIR)$@ && chmod 755 $(DESTDIR)$@ 20 | 21 | $(DEST_ETAGS): 22 | - if [ -x $(DEST_CTAGS) ]; then \ 23 | @@ -153,7 +157,8 @@ install-cman: $(DEST_CMAN) 24 | install-eman: $(DEST_EMAN) 25 | 26 | $(DEST_CMAN): $(man1dir) $(MANPAGE) FORCE 27 | - - $(INSTALL_DATA) $(srcdir)/$(MANPAGE) $@ && chmod 644 $@ 28 | + $(srcdir)/mkinstalldirs $(DESTDIR)$(man1dir) 29 | + - $(INSTALL_DATA) $(srcdir)/$(MANPAGE) $(DESTDIR)$@ && chmod 644 $(DESTDIR)$@ 30 | 31 | $(DEST_EMAN): 32 | - if [ -f $(DEST_CMAN) ]; then \ 33 | @@ -164,9 +169,11 @@ $(DEST_EMAN): 34 | # install the library 35 | # 36 | $(DEST_READ_LIB): $(READ_LIB) $(libdir) FORCE 37 | + $(srcdir)/mkinstalldirs $(DESTDIR)$(libdir) 38 | $(INSTALL_PROG) $(READ_LIB) $@ && chmod 644 $@ 39 | 40 | $(DEST_READ_INC): $(READ_INC) $(incdir) FORCE 41 | + $(srcdir)/mkinstalldirs $(DESTDIR)$(incdir) 42 | $(INSTALL_PROG) $(READ_INC) $@ && chmod 644 $@ 43 | 44 | 45 | diff -ruN -x '*~' ctags-5.7/vim.c ctags-5.7/vim.c 46 | --- ctags-5.7/vim.c 2006-10-26 12:06:21.000000000 +0900 47 | +++ ctags-5.7/vim.c 2009-08-28 22:21:31.000000000 +0900 48 | @@ -328,7 +328,7 @@ 49 | */ 50 | const unsigned char *cp = line; 51 | 52 | - if ( (int) *cp == '\\' ) 53 | + if ( cp && ( (int) *cp == '\\' ) ) 54 | { 55 | /* 56 | * We are recursively calling this function is the command 57 | @@ -350,9 +350,10 @@ 58 | while (*cp && isspace ((int) *cp)) 59 | ++cp; 60 | } 61 | - else if ( (!strncmp ((const char*) line, "comp", (size_t) 4) == 0) && 62 | - (!strncmp ((const char*) line, "comc", (size_t) 4) == 0) && 63 | - (strncmp ((const char*) line, "com", (size_t) 3) == 0) ) 64 | + else if ( line && 65 | + (!strncmp ((const char*) line, "comp", (size_t) 4) == 0) && 66 | + (!strncmp ((const char*) line, "comc", (size_t) 4) == 0) && 67 | + (strncmp ((const char*) line, "com", (size_t) 3) == 0) ) 68 | { 69 | cp += 2; 70 | if ((int) *++cp == 'm' && (int) *++cp == 'a' && 71 | @@ -394,6 +395,14 @@ 72 | while (*cp && !isspace ((int) *cp)) 73 | ++cp; 74 | } 75 | + else if (!isalnum ((int) *cp)) 76 | + { 77 | + /* 78 | + * Broken syntax: throw away this line 79 | + */ 80 | + cmdProcessed = TRUE; 81 | + goto cleanUp; 82 | + } 83 | } while ( *cp && !isalnum ((int) *cp) ); 84 | 85 | if ( ! *cp ) 86 | diff -up ctags-5.8/css.c.me ctags-5.8/css.c 87 | --- ctags-5.8/css.c.me 2012-02-08 13:59:35.000000000 +0100 88 | +++ ctags-5.8/css.c 2012-02-08 13:55:16.000000000 +0100 89 | @@ -0,0 +1,226 @@ 90 | +/*************************************************************************** 91 | + * css.c 92 | + * Character-based parser for Css definitions 93 | + * Author - Iago Rubio 94 | + **************************************************************************/ 95 | +#include "general.h" 96 | + 97 | +#include 98 | +#include 99 | + 100 | +#include "parse.h" 101 | +#include "read.h" 102 | + 103 | + 104 | +typedef enum eCssKinds { 105 | + K_NONE = -1, K_CLASS, K_SELECTOR, K_ID 106 | +} cssKind; 107 | + 108 | +static kindOption CssKinds [] = { 109 | + { TRUE, 'c', "class", "classes" }, 110 | + { TRUE, 's', "selector", "selectors" }, 111 | + { TRUE, 'i', "id", "identities" } 112 | +}; 113 | + 114 | +typedef enum _CssParserState { // state of parsing 115 | + P_STATE_NONE, // default state 116 | + P_STATE_IN_COMMENT, // into a comment, only multi line in CSS 117 | + P_STATE_IN_SINGLE_STRING, // into a single quoted string 118 | + P_STATE_IN_DOUBLE_STRING, // into a double quoted string 119 | + P_STATE_IN_DEFINITION, // on the body of the style definition, nothing for us 120 | + P_STATE_IN_MEDIA, // on a @media declaration, can be multi-line 121 | + P_STATE_IN_IMPORT, // on a @import declaration, can be multi-line 122 | + P_STATE_IN_NAMESPACE, // on a @namespace declaration 123 | + P_STATE_IN_PAGE, // on a @page declaration 124 | + P_STATE_IN_FONTFACE, // on a @font-face declaration 125 | + P_STATE_AT_END // end of parsing 126 | +} CssParserState; 127 | + 128 | +static void makeCssSimpleTag( vString *name, cssKind kind, boolean delete ) 129 | +{ 130 | + vStringTerminate (name); 131 | + makeSimpleTag (name, CssKinds, kind); 132 | + vStringClear (name); 133 | + if( delete ) 134 | + vStringDelete (name); 135 | +} 136 | + 137 | +static boolean isCssDeclarationAllowedChar( const unsigned char *cp ) 138 | +{ 139 | + return isalnum ((int) *cp) || 140 | + isspace ((int) *cp) || 141 | + *cp == '_' || // allowed char 142 | + *cp == '-' || // allowed char 143 | + *cp == '+' || // allow all sibling in a single tag 144 | + *cp == '>' || // allow all child in a single tag 145 | + *cp == '{' || // allow the start of the declaration 146 | + *cp == '.' || // allow classes and selectors 147 | + *cp == ',' || // allow multiple declarations 148 | + *cp == ':' || // allow pseudo classes 149 | + *cp == '*' || // allow globs as P + * 150 | + *cp == '#'; // allow ids 151 | +} 152 | + 153 | +static CssParserState parseCssDeclaration( const unsigned char **position, cssKind kind ) 154 | +{ 155 | + vString *name = vStringNew (); 156 | + const unsigned char *cp = *position; 157 | + 158 | + // pick to the end of line including children and sibling 159 | + // if declaration is multiline go for the next line 160 | + while ( isCssDeclarationAllowedChar(cp) || 161 | + *cp == '\0' ) // track the end of line into the loop 162 | + { 163 | + if( (int) *cp == '\0' ) 164 | + { 165 | + cp = fileReadLine (); 166 | + if( cp == NULL ){ 167 | + makeCssSimpleTag(name, kind, TRUE); 168 | + *position = cp; 169 | + return P_STATE_AT_END; 170 | + } 171 | + } 172 | + else if( *cp == ',' ) 173 | + { 174 | + makeCssSimpleTag(name, kind, TRUE); 175 | + *position = ++cp; 176 | + return P_STATE_NONE; 177 | + } 178 | + else if( *cp == '{' ) 179 | + { 180 | + makeCssSimpleTag(name, kind, TRUE); 181 | + *position = ++cp; 182 | + return P_STATE_IN_DEFINITION; 183 | + } 184 | + 185 | + vStringPut (name, (int) *cp); 186 | + ++cp; 187 | + } 188 | + 189 | + makeCssSimpleTag(name, kind, TRUE); 190 | + *position = cp; 191 | + 192 | + return P_STATE_NONE; 193 | +} 194 | + 195 | +static CssParserState parseCssLine( const unsigned char *line, CssParserState state ) 196 | +{ 197 | + vString *aux; 198 | + 199 | + while( *line != '\0' ) // fileReadLine returns NULL terminated strings 200 | + { 201 | + while (isspace ((int) *line)) 202 | + ++line; 203 | + switch( state ) 204 | + { 205 | + case P_STATE_NONE: 206 | + // pick first char if alphanumeric is a selector 207 | + if( isalnum ((int) *line) ) 208 | + state = parseCssDeclaration( &line, K_SELECTOR ); 209 | + else if( *line == '.' ) // a class 210 | + state = parseCssDeclaration( &line, K_CLASS ); 211 | + else if( *line == '#' ) // an id 212 | + state = parseCssDeclaration( &line, K_ID ); 213 | + else if( *line == '@' ) // at-rules, we'll ignore them 214 | + { 215 | + ++line; 216 | + aux = vStringNew(); 217 | + while( !isspace((int) *line) ) 218 | + { 219 | + vStringPut (aux, (int) *line); 220 | + ++line; 221 | + } 222 | + vStringTerminate (aux); 223 | + if( strcmp( aux->buffer, "media" ) == 0 ) 224 | + state = P_STATE_IN_MEDIA; 225 | + else if ( strcmp( aux->buffer, "import" ) == 0 ) 226 | + state = P_STATE_IN_IMPORT; 227 | + else if ( strcmp( aux->buffer, "namespace" ) == 0 ) 228 | + state = P_STATE_IN_NAMESPACE; 229 | + else if ( strcmp( aux->buffer, "page" ) == 0 ) 230 | + state = P_STATE_IN_PAGE; 231 | + else if ( strcmp( aux->buffer, "font-face" ) == 0 ) 232 | + state = P_STATE_IN_FONTFACE; 233 | + vStringDelete (aux); 234 | + } 235 | + else if( *line == '*' && *(line-1) == '/' ) // multi-line comment 236 | + state = P_STATE_IN_COMMENT; 237 | + break; 238 | + case P_STATE_IN_COMMENT: 239 | + if( *line == '/' && *(line-1) == '*') 240 | + state = P_STATE_NONE; 241 | + break; 242 | + case P_STATE_IN_SINGLE_STRING: 243 | + if( *line == '\'' && *(line-1) != '\\' ) 244 | + state = P_STATE_IN_DEFINITION; // PAGE, FONTFACE and DEFINITION are treated the same way 245 | + break; 246 | + case P_STATE_IN_DOUBLE_STRING: 247 | + if( *line=='"' && *(line-1) != '\\' ) 248 | + state = P_STATE_IN_DEFINITION; // PAGE, FONTFACE and DEFINITION are treated the same way 249 | + break; 250 | + case P_STATE_IN_MEDIA: 251 | + // skip to start of media body or line end 252 | + while( *line != '{' ) 253 | + { 254 | + if( *line == '\0' ) 255 | + break; 256 | + ++line; 257 | + } 258 | + if( *line == '{' ) 259 | + state = P_STATE_NONE; 260 | + break; 261 | + case P_STATE_IN_IMPORT: 262 | + case P_STATE_IN_NAMESPACE: 263 | + // skip to end of declaration or line end 264 | + while( *line != ';' ) 265 | + { 266 | + if( *line == '\0' ) 267 | + break; 268 | + ++line; 269 | + } 270 | + if( *line == ';' ) 271 | + state = P_STATE_NONE; 272 | + break; 273 | + case P_STATE_IN_PAGE: 274 | + case P_STATE_IN_FONTFACE: 275 | + case P_STATE_IN_DEFINITION: 276 | + if( *line == '}' ) 277 | + state = P_STATE_NONE; 278 | + else if( *line == '\'' ) 279 | + state = P_STATE_IN_SINGLE_STRING; 280 | + else if( *line == '"' ) 281 | + state = P_STATE_IN_DOUBLE_STRING; 282 | + break; 283 | + case P_STATE_AT_END: 284 | + return state; 285 | + break; 286 | + } 287 | + line++; 288 | + } 289 | + return state; 290 | +} 291 | + 292 | +static void findCssTags (void) 293 | +{ 294 | + const unsigned char *line; 295 | + CssParserState state = P_STATE_NONE; 296 | + 297 | + while ( (line = fileReadLine ()) != NULL ) 298 | + { 299 | + state = parseCssLine( line, state ); 300 | + if( state==P_STATE_AT_END ) return; 301 | + } 302 | +} 303 | + 304 | +/* parser definition */ 305 | +extern parserDefinition* CssParser (void) 306 | +{ 307 | + static const char *const extensions [] = { "css", NULL }; 308 | + parserDefinition* def = parserNew ("CSS"); 309 | + def->kinds = CssKinds; 310 | + def->kindCount = KIND_COUNT (CssKinds); 311 | + def->extensions = extensions; 312 | + def->parser = findCssTags; 313 | + return def; 314 | +} 315 | + 316 | diff -up ctags-5.8/parsers.h.me ctags-5.8/parsers.h 317 | --- ctags-5.8/parsers.h.me 2012-02-08 13:56:46.000000000 +0100 318 | +++ ctags-5.8/parsers.h 2012-02-08 13:57:25.000000000 +0100 319 | @@ -26,6 +26,7 @@ 320 | CppParser, \ 321 | CsharpParser, \ 322 | CobolParser, \ 323 | + CssParser, \ 324 | DosBatchParser, \ 325 | EiffelParser, \ 326 | ErlangParser, \ 327 | diff -up ctags-5.8/source.mak.me ctags-5.8/source.mak 328 | --- ctags-5.8/source.mak.me 2012-02-08 13:58:02.000000000 +0100 329 | +++ ctags-5.8/source.mak 2012-02-08 13:58:42.000000000 +0100 330 | @@ -17,6 +17,7 @@ SOURCES = \ 331 | beta.c \ 332 | c.c \ 333 | cobol.c \ 334 | + css.c \ 335 | dosbatch.c \ 336 | eiffel.c \ 337 | entry.c \ 338 | @@ -79,6 +80,7 @@ OBJECTS = \ 339 | beta.$(OBJEXT) \ 340 | c.$(OBJEXT) \ 341 | cobol.$(OBJEXT) \ 342 | + css.$(OBJEXT) \ 343 | dosbatch.$(OBJEXT) \ 344 | eiffel.$(OBJEXT) \ 345 | entry.$(OBJEXT) \ 346 | diff -up ctags-5.8/css.c.me ctags-5.8/css.c 347 | --- ctags-5.8/css.c.me 2012-10-18 22:03:20.126163700 +0200 348 | +++ ctags-5.8/css.c 2012-10-18 22:04:03.237107358 +0200 349 | @@ -73,10 +73,11 @@ static CssParserState parseCssDeclaratio 350 | { 351 | if( (int) *cp == '\0' ) 352 | { 353 | + /* assign position to the end of line. */ 354 | + *position = cp; 355 | cp = fileReadLine (); 356 | if( cp == NULL ){ 357 | makeCssSimpleTag(name, kind, TRUE); 358 | - *position = cp; 359 | return P_STATE_AT_END; 360 | } 361 | } 362 | diff -Naur ctags-5.8.orig/lregex.c ctags-5.8/lregex.c 363 | --- ctags-5.8.orig/lregex.c 2007-09-10 04:36:48.000000000 +0200 364 | +++ ctags-5.8/lregex.c 2014-04-14 21:09:17.716000000 +0200 365 | @@ -408,7 +408,7 @@ 366 | const char* regexfile = parameter + 1; 367 | FILE* const fp = fopen (regexfile, "r"); 368 | if (fp == NULL) 369 | - error (WARNING | PERROR, regexfile); 370 | + error (WARNING | PERROR, "%s", regexfile); 371 | else 372 | { 373 | vString* const regex = vStringNew (); 374 | diff -r -u ctags-5.8.orig/routines.c ctags-5.8/routines.c 375 | --- ctags-5.8.orig/routines.c 2013-06-13 10:42:08.048576327 -0400 376 | +++ ctags-5.8/routines.c 2013-06-13 10:48:25.150366836 -0400 377 | @@ -757,13 +757,13 @@ 378 | else if (cp [0] != PATH_SEPARATOR) 379 | cp = slashp; 380 | #endif 381 | - strcpy (cp, slashp + 3); 382 | + memmove (cp, slashp + 3, strlen(slashp + 3) + 1); 383 | slashp = cp; 384 | continue; 385 | } 386 | else if (slashp [2] == PATH_SEPARATOR || slashp [2] == '\0') 387 | { 388 | - strcpy (slashp, slashp + 2); 389 | + memmove (slashp, slashp + 2, strlen(slashp + 2) + 1); 390 | continue; 391 | } 392 | } 393 | diff -up ctags-5.8/ocaml.c.me ctags-5.8/ocaml.c 394 | --- ctags-5.8/ocaml.c.me 2012-08-02 12:42:21.652211192 +0200 395 | +++ ctags-5.8/ocaml.c 2012-08-02 13:06:59.751283639 +0200 396 | @@ -72,6 +72,7 @@ typedef enum { 397 | OcaKEYWORD_if, 398 | OcaKEYWORD_in, 399 | OcaKEYWORD_let, 400 | + OcaKEYWORD_value, 401 | OcaKEYWORD_match, 402 | OcaKEYWORD_method, 403 | OcaKEYWORD_module, 404 | @@ -145,7 +146,7 @@ static const ocaKeywordDesc OcamlKeyword 405 | { "try" , OcaKEYWORD_try }, 406 | { "type" , OcaKEYWORD_type }, 407 | { "val" , OcaKEYWORD_val }, 408 | - { "value" , OcaKEYWORD_let }, /* just to handle revised syntax */ 409 | + { "value" , OcaKEYWORD_value }, /* just to handle revised syntax */ 410 | { "virtual" , OcaKEYWORD_virtual }, 411 | { "while" , OcaKEYWORD_while }, 412 | { "with" , OcaKEYWORD_with }, 413 | @@ -297,7 +298,6 @@ static void eatComment (lexingState * st 414 | if (st->cp == NULL) 415 | return; 416 | c = st->cp; 417 | - continue; 418 | } 419 | /* we've reached the end of the comment */ 420 | else if (*c == ')' && lastIsStar) 421 | @@ -308,13 +308,33 @@ static void eatComment (lexingState * st 422 | { 423 | st->cp = c; 424 | eatComment (st); 425 | + 426 | c = st->cp; 427 | + if (c == NULL) 428 | + return; 429 | + 430 | lastIsStar = FALSE; 431 | + c++; 432 | } 433 | + /* OCaml has a rule which says : 434 | + * 435 | + * "Comments do not occur inside string or character literals. 436 | + * Nested comments are handled correctly." 437 | + * 438 | + * So if we encounter a string beginning, we must parse it to 439 | + * get a good comment nesting (bug ID: 3117537) 440 | + */ 441 | + else if (*c == '"') 442 | + { 443 | + st->cp = c; 444 | + eatString (st); 445 | + c = st->cp; 446 | + } 447 | else 448 | + { 449 | lastIsStar = '*' == *c; 450 | - 451 | - c++; 452 | + c++; 453 | + } 454 | } 455 | 456 | st->cp = c; 457 | @@ -554,8 +574,7 @@ static int getLastNamedIndex ( void ) 458 | 459 | for (i = stackIndex - 1; i >= 0; --i) 460 | { 461 | - if (stack[i].contextName->buffer && 462 | - strlen (stack[i].contextName->buffer) > 0) 463 | + if (vStringLength (stack[i].contextName) > 0) 464 | { 465 | return i; 466 | } 467 | @@ -866,6 +885,11 @@ static void prepareTag (tagEntryInfo * t 468 | tag->kindName = OcamlKinds[kind].name; 469 | tag->kind = OcamlKinds[kind].letter; 470 | 471 | + if (kind == K_MODULE) 472 | + { 473 | + tag->lineNumberEntry = TRUE; 474 | + tag->lineNumber = 1; 475 | + } 476 | parentIndex = getLastNamedIndex (); 477 | if (parentIndex >= 0) 478 | { 479 | @@ -880,9 +904,12 @@ static void prepareTag (tagEntryInfo * t 480 | * more information to it in the future */ 481 | static void addTag (vString * const ident, int kind) 482 | { 483 | - tagEntryInfo toCreate; 484 | - prepareTag (&toCreate, ident, kind); 485 | - makeTagEntry (&toCreate); 486 | + if (OcamlKinds [kind].enabled && ident != NULL && vStringLength (ident) > 0) 487 | + { 488 | + tagEntryInfo toCreate; 489 | + prepareTag (&toCreate, ident, kind); 490 | + makeTagEntry (&toCreate); 491 | + } 492 | } 493 | 494 | boolean needStrongPoping = FALSE; 495 | @@ -942,15 +969,17 @@ static void typeRecord (vString * const 496 | } 497 | 498 | /* handle : 499 | - * exception ExceptionName ... */ 500 | + * exception ExceptionName of ... */ 501 | static void exceptionDecl (vString * const ident, ocaToken what) 502 | { 503 | if (what == OcaIDENTIFIER) 504 | { 505 | addTag (ident, K_EXCEPTION); 506 | } 507 | - /* don't know what to do on else... */ 508 | - 509 | + else /* probably ill-formed, give back to global scope */ 510 | + { 511 | + globalScope (ident, what); 512 | + } 513 | toDoNext = &globalScope; 514 | } 515 | 516 | @@ -1006,7 +1035,6 @@ static void constructorValidation (vStri 517 | */ 518 | static void typeDecl (vString * const ident, ocaToken what) 519 | { 520 | - 521 | switch (what) 522 | { 523 | /* parameterized */ 524 | @@ -1046,7 +1074,6 @@ static void typeDecl (vString * const id 525 | * let typeRecord handle it. */ 526 | static void typeSpecification (vString * const ident, ocaToken what) 527 | { 528 | - 529 | switch (what) 530 | { 531 | case OcaIDENTIFIER: 532 | @@ -1243,8 +1270,14 @@ static void localLet (vString * const id 533 | * than the let definitions. 534 | * Used after a match ... with, or a function ... or fun ... 535 | * because their syntax is similar. */ 536 | -static void matchPattern (vString * const UNUSED (ident), ocaToken what) 537 | +static void matchPattern (vString * const ident, ocaToken what) 538 | { 539 | + /* keep track of [], as it 540 | + * can be used in patterns and can 541 | + * mean the end of match expression in 542 | + * revised syntax */ 543 | + static int braceCount = 0; 544 | + 545 | switch (what) 546 | { 547 | case Tok_To: 548 | @@ -1252,6 +1285,14 @@ static void matchPattern (vString * cons 549 | toDoNext = &mayRedeclare; 550 | break; 551 | 552 | + case Tok_BRL: 553 | + braceCount++; 554 | + break; 555 | + 556 | + case OcaKEYWORD_value: 557 | + popLastNamed (); 558 | + globalScope (ident, what); 559 | + break; 560 | 561 | case OcaKEYWORD_in: 562 | popLastNamed (); 563 | @@ -1269,6 +1310,11 @@ static void mayRedeclare (vString * cons 564 | { 565 | switch (what) 566 | { 567 | + case OcaKEYWORD_value: 568 | + /* let globalScope handle it */ 569 | + globalScope (ident, what); 570 | + break; 571 | + 572 | case OcaKEYWORD_let: 573 | case OcaKEYWORD_val: 574 | toDoNext = localLet; 575 | @@ -1388,6 +1434,7 @@ static void classSpecif (vString * const 576 | * nearly a copy/paste of globalLet. */ 577 | static void methodDecl (vString * const ident, ocaToken what) 578 | { 579 | + 580 | switch (what) 581 | { 582 | case Tok_PARL: 583 | @@ -1435,6 +1482,7 @@ vString *lastModule; 584 | */ 585 | static void moduleSpecif (vString * const ident, ocaToken what) 586 | { 587 | + 588 | switch (what) 589 | { 590 | case OcaKEYWORD_functor: 591 | @@ -1566,7 +1614,7 @@ static void globalScope (vString * const 592 | { 593 | /* Do not touch, this is used only by the global scope 594 | * to handle an 'and' */ 595 | - static parseNext previousParser = NULL; 596 | + static parseNext previousParser = &globalScope; 597 | 598 | switch (what) 599 | { 600 | @@ -1608,6 +1656,7 @@ static void globalScope (vString * const 601 | /* val is mixed with let as global 602 | * to be able to handle mli & new syntax */ 603 | case OcaKEYWORD_val: 604 | + case OcaKEYWORD_value: 605 | case OcaKEYWORD_let: 606 | cleanupPreviousParser (); 607 | toDoNext = &globalLet; 608 | @@ -1617,7 +1666,7 @@ static void globalScope (vString * const 609 | case OcaKEYWORD_exception: 610 | cleanupPreviousParser (); 611 | toDoNext = &exceptionDecl; 612 | - previousParser = NULL; 613 | + previousParser = &globalScope; 614 | break; 615 | 616 | /* must be a #line directive, discard the 617 | @@ -1769,7 +1818,7 @@ static void computeModuleName ( void ) 618 | if (isLowerAlpha (moduleName->buffer[0])) 619 | moduleName->buffer[0] += ('A' - 'a'); 620 | 621 | - makeSimpleTag (moduleName, OcamlKinds, K_MODULE); 622 | + addTag (moduleName, K_MODULE); 623 | vStringDelete (moduleName); 624 | } 625 | 626 | @@ -1779,6 +1828,7 @@ static void initStack ( void ) 627 | int i; 628 | for (i = 0; i < OCAML_MAX_STACK_SIZE; ++i) 629 | stack[i].contextName = vStringNew (); 630 | + stackIndex = 0; 631 | } 632 | 633 | static void clearStack ( void ) 634 | @@ -1794,8 +1844,8 @@ static void findOcamlTags (void) 635 | lexingState st; 636 | ocaToken tok; 637 | 638 | - computeModuleName (); 639 | initStack (); 640 | + computeModuleName (); 641 | tempIdent = vStringNew (); 642 | lastModule = vStringNew (); 643 | lastClass = vStringNew (); 644 | --- ctags/jscript.c.orig 2008-10-13 00:27:38.000000000 +0200 645 | +++ ctags/jscript.c 2014-09-30 13:49:34.837349283 +0200 646 | @@ -1,5 +1,5 @@ 647 | /* 648 | - * $Id: jscript.c 666 2008-05-15 17:47:31Z dfishburn $ 649 | + * $Id: jscript.c 791 2012-10-24 01:13:13Z dfishburn $ 650 | * 651 | * Copyright (c) 2003, Darren Hiebert 652 | * 653 | @@ -215,6 +215,7 @@ 654 | * Tag generation functions 655 | */ 656 | 657 | +/* 658 | static void makeConstTag (tokenInfo *const token, const jsKind kind) 659 | { 660 | if (JsKinds [kind].enabled && ! token->ignoreTag ) 661 | @@ -238,12 +239,13 @@ 662 | 663 | if (JsKinds [kind].enabled && ! token->ignoreTag ) 664 | { 665 | - /* 666 | + * 667 | * If a scope has been added to the token, change the token 668 | * string to include the scope when making the tag. 669 | - */ 670 | + * 671 | if ( vStringLength(token->scope) > 0 ) 672 | { 673 | + * 674 | fulltag = vStringNew (); 675 | vStringCopy(fulltag, token->scope); 676 | vStringCatS (fulltag, "."); 677 | @@ -251,8 +253,54 @@ 678 | vStringTerminate(fulltag); 679 | vStringCopy(token->string, fulltag); 680 | vStringDelete (fulltag); 681 | + * 682 | + jsKind parent_kind = JSTAG_CLASS; 683 | + 684 | + * 685 | + * if we're creating a function (and not a method), 686 | + * guess we're inside another function 687 | + * 688 | + if (kind == JSTAG_FUNCTION) 689 | + parent_kind = JSTAG_FUNCTION; 690 | + 691 | + e.extensionFields.scope[0] = JsKinds [parent_kind].name; 692 | + e.extensionFields.scope[1] = vStringValue (token->scope); 693 | } 694 | - makeConstTag (token, kind); 695 | + * makeConstTag (token, kind); * 696 | + makeTagEntry (&e); 697 | + } 698 | +} 699 | +*/ 700 | + 701 | +static void makeJsTag (tokenInfo *const token, const jsKind kind) 702 | +{ 703 | + if (JsKinds [kind].enabled && ! token->ignoreTag ) 704 | + { 705 | + const char *const name = vStringValue (token->string); 706 | + tagEntryInfo e; 707 | + initTagEntry (&e, name); 708 | + 709 | + e.lineNumber = token->lineNumber; 710 | + e.filePosition = token->filePosition; 711 | + e.kindName = JsKinds [kind].name; 712 | + e.kind = JsKinds [kind].letter; 713 | + 714 | + if ( vStringLength(token->scope) > 0 ) 715 | + { 716 | + jsKind parent_kind = JSTAG_CLASS; 717 | + 718 | + /* 719 | + * If we're creating a function (and not a method), 720 | + * guess we're inside another function 721 | + */ 722 | + if (kind == JSTAG_FUNCTION) 723 | + parent_kind = JSTAG_FUNCTION; 724 | + 725 | + e.extensionFields.scope[0] = JsKinds [parent_kind].name; 726 | + e.extensionFields.scope[1] = vStringValue (token->scope); 727 | + } 728 | + 729 | + makeTagEntry (&e); 730 | } 731 | } 732 | 733 | -------------------------------------------------------------------------------- /patches/ctags-5.8-for-gcc_12.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp ctags-5.8.orig/general.h ctags-5.8/general.h 2 | --- ctags-5.8.orig/general.h 2007-05-03 03:21:08.000000000 +0000 3 | +++ ctags-5.8/general.h 2021-08-31 07:24:59.919960558 +0000 4 | @@ -57,7 +57,7 @@ 5 | * to prevent warnings about unused variables. 6 | */ 7 | #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !defined (__GNUG__) 8 | -# define __unused__ __attribute__((unused)) 9 | +# define __unused__ __attribute_maybe_unused__ 10 | # define __printf__(s,f) __attribute__((format (printf, s, f))) 11 | #else 12 | # define __unused__ 13 | -------------------------------------------------------------------------------- /patches/firefox-100-add-loongarch.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp firefox-100.0.orig/ipc/chromium/src/build/build_config.h firefox-100.0/ipc/chromium/src/build/build_config.h 2 | --- firefox-100.0.orig/ipc/chromium/src/build/build_config.h 2022-04-28 22:02:47.000000000 +0000 3 | +++ firefox-100.0/ipc/chromium/src/build/build_config.h 2022-06-08 07:15:25.232514650 +0000 4 | @@ -125,6 +125,9 @@ 5 | #elif defined(__riscv) && __riscv_xlen == 64 6 | # define ARCH_CPU_RISCV64 1 7 | # define ARCH_CPU_64_BITS 1 8 | +#elif defined(__loongarch_lp64) 9 | +# define ARCH_CPU_LOONGARCH64 1 10 | +# define ARCH_CPU_64_BITS 1 11 | #else 12 | # error Please add support for your architecture in build/build_config.h 13 | #endif 14 | diff -Nurp firefox-100.0.orig/third_party/libwebrtc/build/build_config.h firefox-100.0/third_party/libwebrtc/build/build_config.h 15 | --- firefox-100.0.orig/third_party/libwebrtc/build/build_config.h 2022-04-28 22:03:52.000000000 +0000 16 | +++ firefox-100.0/third_party/libwebrtc/build/build_config.h 2022-06-08 07:15:25.233514649 +0000 17 | @@ -206,6 +206,10 @@ 18 | #define ARCH_CPU_SPARC 1 19 | #define ARCH_CPU_32_BITS 1 20 | #define ARCH_CPU_BIG_ENDIAN 1 21 | +#elif defined(__loongarch_lp64) 22 | +#define ARCH_CPU_LOONGARCH64 1 23 | +#define ARCH_CPU_64_BITS 1 24 | +#define ARCH_CPU_LITTLE_ENDIAN 1 25 | #else 26 | #error Please add support for your architecture in build/build_config.h 27 | #endif 28 | diff -Nurp firefox-100.0.orig/toolkit/moz.configure firefox-100.0/toolkit/moz.configure 29 | --- firefox-100.0.orig/toolkit/moz.configure 2022-04-28 23:01:47.000000000 +0000 30 | +++ firefox-100.0/toolkit/moz.configure 2022-06-08 07:15:25.234514649 +0000 31 | @@ -2156,7 +2156,7 @@ with only_when(compile_environment | art 32 | flac_only = True 33 | elif target.cpu == "x86_64": 34 | flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"] 35 | - elif target.cpu in ("x86", "arm", "aarch64"): 36 | + elif target.cpu in ("x86", "arm", "aarch64", "loongarch64"): 37 | flac_only = True 38 | else: 39 | enable = False 40 | -------------------------------------------------------------------------------- /patches/firefox-100-for-clfs.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp firefox-100.0.orig/build/moz.configure/pkg.configure firefox-100.0/build/moz.configure/pkg.configure 2 | --- firefox-100.0.orig/build/moz.configure/pkg.configure 2022-04-28 22:02:34.000000000 +0000 3 | +++ firefox-100.0/build/moz.configure/pkg.configure 2022-06-08 07:27:46.771483492 +0000 4 | @@ -63,7 +63,7 @@ def pkg_config_vars(target, sysroot_path 5 | PKG_CONFIG_LIBDIR=pathsep.join( 6 | os.path.join(sysroot_path, d) 7 | for d in ( 8 | - "usr/lib/pkgconfig", 9 | + "usr/lib64/pkgconfig", 10 | "usr/lib/{}/pkgconfig".format(multiarch_dir), 11 | "usr/share/pkgconfig", 12 | ) 13 | -------------------------------------------------------------------------------- /patches/firefox-105-fix-for-gcc13.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp firefox-105.0.orig/toolkit/components/telemetry/pingsender/pingsender.cpp firefox-105.0/toolkit/components/telemetry/pingsender/pingsender.cpp 2 | --- firefox-105.0.orig/toolkit/components/telemetry/pingsender/pingsender.cpp 2022-09-15 18:50:28.000000000 +0000 3 | +++ firefox-105.0/toolkit/components/telemetry/pingsender/pingsender.cpp 2022-09-20 04:46:11.421696481 +0000 4 | @@ -9,6 +9,7 @@ 5 | #include 6 | #include 7 | #include 8 | +#include 9 | #include 10 | 11 | #include 12 | diff -Nurp firefox-105.0.orig/gfx/2d/Rect.h firefox-105.0/gfx/2d/Rect.h 13 | --- firefox-105.0.orig/gfx/2d/Rect.h 2022-09-15 18:49:09.000000000 +0000 14 | +++ firefox-105.0/gfx/2d/Rect.h 2022-09-20 04:35:44.173722836 +0000 15 | @@ -15,6 +15,7 @@ 16 | #include "mozilla/Maybe.h" 17 | 18 | #include 19 | +#include 20 | 21 | namespace mozilla { 22 | 23 | -------------------------------------------------------------------------------- /patches/firefox-105-fix-jit-for-loongarch64.patch: -------------------------------------------------------------------------------- 1 | diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp 2 | --- a/js/xpconnect/src/XPCJSContext.cpp 3 | +++ b/js/xpconnect/src/XPCJSContext.cpp 4 | @@ -933,7 +933,8 @@ static void LoadStartupJSPrefs(XPCJSCont 5 | StaticPrefs::javascript_options_jit_full_debug_checks_DoNotUseDirectly()); 6 | #endif 7 | 8 | -#if !defined(JS_CODEGEN_MIPS32) && !defined(JS_CODEGEN_MIPS64) 9 | +#if !defined(JS_CODEGEN_MIPS32) && !defined(JS_CODEGEN_MIPS64) && \ 10 | + !defined(JS_CODEGEN_LOONG64) 11 | JS_SetGlobalJitCompilerOption( 12 | cx, JSJITCOMPILER_SPECTRE_INDEX_MASKING, 13 | StaticPrefs::javascript_options_spectre_index_masking_DoNotUseDirectly()); 14 | diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml 15 | --- a/modules/libpref/init/StaticPrefList.yaml 16 | +++ b/modules/libpref/init/StaticPrefList.yaml 17 | @@ -7102,10 +7102,10 @@ 18 | mirror: always # LoadStartupJSPrefs 19 | do_not_use_directly: true 20 | 21 | -#if !defined(JS_CODEGEN_MIPS32) && !defined(JS_CODEGEN_MIPS64) 22 | +#if !defined(JS_CODEGEN_MIPS32) && !defined(JS_CODEGEN_MIPS64) && !defined(JS_CODEGEN_LOONG64) 23 | # Spectre security vulnerability mitigations for the JS JITs. 24 | # 25 | - # NOTE: The MIPS backends do not support these mitigations (and generally 26 | + # NOTE: The MIPS and LoongArch backends do not support these mitigations (and generally 27 | # do not need them). In that case, leave the pref unlisted with its 28 | # default value of false. 29 | - name: javascript.options.spectre.index_masking 30 | @@ -7137,7 +7137,7 @@ 31 | value: true 32 | mirror: always # LoadStartupJSPrefs 33 | do_not_use_directly: true 34 | -#endif // !defined(JS_CODEGEN_MIPSXX) 35 | +#endif // !defined(JS_CODEGEN_MIPSXX) && !defined(JS_CODEGEN_LOONG64) 36 | 37 | # Separate pref to override the values of the Spectre-related prefs above for 38 | # isolated web content processes, where we don't need these mitigations. 39 | -------------------------------------------------------------------------------- /patches/firefox-110-fix-rust.patch: -------------------------------------------------------------------------------- 1 | From 368f59d5e49ef460a486d5782dfc1d0e3fb53f93 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Wed, 1 Mar 2023 17:06:40 +0000 4 | Subject: [PATCH] firefox 110 fix rust. 5 | 6 | --- 7 | third_party/rust/authenticator/build.rs | 2 ++ 8 | .../rust/authenticator/src/transport/linux/hidwrapper.rs | 3 +++ 9 | .../authenticator/src/transport/linux/ioctl_loongarch64.rs | 5 +++++ 10 | third_party/rust/cty/src/lib.rs | 1 + 11 | third_party/rust/nix/src/sys/ioctl/linux.rs | 1 + 12 | 5 files changed, 12 insertions(+) 13 | create mode 100644 third_party/rust/authenticator/src/transport/linux/ioctl_loongarch64.rs 14 | 15 | diff --git a/third_party/rust/authenticator/build.rs b/third_party/rust/authenticator/build.rs 16 | index c972d85b89..3b2f12171f 100644 17 | --- a/third_party/rust/authenticator/build.rs 18 | +++ b/third_party/rust/authenticator/build.rs 19 | @@ -47,6 +47,8 @@ fn main() { 20 | "ioctl_s390xbe.rs" 21 | } else if cfg!(all(target_arch = "riscv64", target_endian = "little")) { 22 | "ioctl_riscv64.rs" 23 | + } else if cfg!(all(target_arch = "loongarch64", target_endian = "little")) { 24 | + "ioctl_loongarch64.rs" 25 | } else { 26 | panic!("architecture not supported"); 27 | }; 28 | diff --git a/third_party/rust/authenticator/src/transport/linux/hidwrapper.rs b/third_party/rust/authenticator/src/transport/linux/hidwrapper.rs 29 | index 82aabc6301..bc8582c5b1 100644 30 | --- a/third_party/rust/authenticator/src/transport/linux/hidwrapper.rs 31 | +++ b/third_party/rust/authenticator/src/transport/linux/hidwrapper.rs 32 | @@ -49,3 +49,6 @@ include!("ioctl_s390xbe.rs"); 33 | 34 | #[cfg(all(target_arch = "riscv64", target_endian = "little"))] 35 | include!("ioctl_riscv64.rs"); 36 | + 37 | +#[cfg(all(target_arch = "loongarch64", target_endian = "little"))] 38 | +include!("ioctl_loongarch64.rs"); 39 | diff --git a/third_party/rust/authenticator/src/transport/linux/ioctl_loongarch64.rs b/third_party/rust/authenticator/src/transport/linux/ioctl_loongarch64.rs 40 | new file mode 100644 41 | index 0000000000..a784e9bf46 42 | --- /dev/null 43 | +++ b/third_party/rust/authenticator/src/transport/linux/ioctl_loongarch64.rs 44 | @@ -0,0 +1,5 @@ 45 | +/* automatically generated by rust-bindgen */ 46 | + 47 | +pub type __u32 = ::std::os::raw::c_uint; 48 | +pub const _HIDIOCGRDESCSIZE: __u32 = 2147764225; 49 | +pub const _HIDIOCGRDESC: __u32 = 2416199682; 50 | diff --git a/third_party/rust/cty/src/lib.rs b/third_party/rust/cty/src/lib.rs 51 | index 971c9cb3a9..80b8f3f291 100644 52 | --- a/third_party/rust/cty/src/lib.rs 53 | +++ b/third_party/rust/cty/src/lib.rs 54 | @@ -24,6 +24,7 @@ pub use pwd::*; 55 | target_arch = "powerpc", 56 | target_arch = "powerpc64", 57 | target_arch = "s390x", 58 | + target_arch = "loongarch64", 59 | target_arch = "riscv32", 60 | target_arch = "riscv64"))] 61 | mod ad { 62 | diff --git a/third_party/rust/nix/src/sys/ioctl/linux.rs b/third_party/rust/nix/src/sys/ioctl/linux.rs 63 | index 971c9cb3a9..80b8f3f291 100644 64 | --- a/third_party/rust/nix/src/sys/ioctl/linux.rs 65 | +++ b/third_party/rust/nix/src/sys/ioctl/linux.rs 66 | @@ -41,6 +41,7 @@ mod consts { 67 | target_arch = "s390x", 68 | target_arch = "x86_64", 69 | target_arch = "aarch64", 70 | + target_arch = "loongarch64", 71 | target_arch = "riscv32", 72 | target_arch = "riscv64" 73 | ))] 74 | -- 75 | 2.31.1 76 | -------------------------------------------------------------------------------- /patches/gc-8.0.6-add-loongarch.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp gc-8.0.6.orig/include/private/gcconfig.h gc-8.0.6/include/private/gcconfig.h 2 | --- gc-8.0.6.orig/include/private/gcconfig.h 2021-09-28 20:47:22.000000000 +0000 3 | +++ gc-8.0.6/include/private/gcconfig.h 2021-12-16 08:05:35.137556347 +0000 4 | @@ -238,6 +238,10 @@ EXTERN_C_BEGIN 5 | # define VAX 6 | # define mach_type_known 7 | # endif 8 | +# if defined(__loongarch_lp64) 9 | +# define LOONGARCH64 10 | +# define mach_type_known 11 | +# endif 12 | # if defined(mips) || defined(__mips) || defined(_mips) 13 | # define MIPS 14 | # if defined(nec_ews) || defined(_nec_ews) 15 | @@ -1732,6 +1736,26 @@ EXTERN_C_BEGIN 16 | # define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */ 17 | # endif 18 | 19 | +# ifdef LOONGARCH64 20 | +# define MACH_TYPE "LOONGARCH64" 21 | +# ifdef LINUX 22 | +# define OS_TYPE "LINUX" 23 | +# define DYNAMIC_LOADING 24 | + extern int _end[]; 25 | +# pragma weak __data_start 26 | + extern int __data_start[]; 27 | +# define DATASTART ((ptr_t)(__data_start)) 28 | +# define DATAEND ((ptr_t)(_end)) 29 | +# define CPP_WORDSZ 64 30 | +# define ALIGNMENT (64/8) 31 | +# ifndef HBLKSIZE 32 | +# define HBLKSIZE 4096 33 | +# endif 34 | +# define LINUX_STACKBOTTOM 35 | +# endif 36 | +# endif 37 | + 38 | + 39 | # ifdef MIPS 40 | # define MACH_TYPE "MIPS" 41 | # ifdef LINUX 42 | diff -Nurp gc-8.0.6.orig/os_dep.c gc-8.0.6/os_dep.c 43 | --- gc-8.0.6.orig/os_dep.c 2021-09-28 20:47:22.000000000 +0000 44 | +++ gc-8.0.6/os_dep.c 2021-12-16 08:06:36.491553769 +0000 45 | @@ -3144,7 +3144,7 @@ GC_API GC_push_other_roots_proc GC_CALL 46 | # ifndef SEGV_ACCERR 47 | # define SEGV_ACCERR 2 48 | # endif 49 | -# if defined(AARCH64) || defined(ARM32) || defined(MIPS) \ 50 | +# if defined(AARCH64) || defined(ARM32) || defined(MIPS) || defined(LOONGARCH64) \ 51 | || __FreeBSD__ >= 7 52 | # define CODE_OK (si -> si_code == SEGV_ACCERR) 53 | # elif defined(POWERPC) 54 | -------------------------------------------------------------------------------- /patches/gpm-1.20.1-weak-wgetch.patch: -------------------------------------------------------------------------------- 1 | --- gpm-1.20.1/src/lib/libcurses.c.weak-wgetch 2002-12-24 17:57:16.000000000 -0500 2 | +++ gpm-1.20.1/src/lib/libcurses.c 2004-03-22 15:51:24.000000000 -0500 3 | @@ -41,7 +41,12 @@ 4 | #endif /* HAVE_NCURSES_CURSES_H */ 5 | #endif /* HAVE_NCURSES_H */ 6 | 7 | -#define GET(win) ((win) ? wgetch(win) : getch()) 8 | +/* If win != NULL, it must have been created by ncurses anyway. 9 | + Avoid circular library dependencies. */ 10 | +#pragma weak wgetch 11 | +#pragma weak stdscr 12 | + 13 | +#define GET(win) ((win && wgetch) ? wgetch(win) : getch()) 14 | 15 | int Gpm_Wgetch(WINDOW *win) 16 | { 17 | --- gpm-1.20.1/configure.ac.weak-wgetch 2004-03-22 15:49:51.000000000 -0500 18 | +++ gpm-1.20.1/configure.ac.footer 2004-03-22 15:51:24.000000000 -0500 19 | @@ -115,7 +115,7 @@ 20 | AC_CHECK_LIB($i, wgetch,,,$TERMLIBS) 21 | else :; fi 22 | done 23 | - SHARED_LIBS="$LIBS $TERMLIBS -lc" 24 | + SHARED_LIBS="-lc" 25 | LIBS=$SAVELIBS ;; 26 | esac 27 | -------------------------------------------------------------------------------- /patches/gpm-1.20.7-consolidated-1.patch: -------------------------------------------------------------------------------- 1 | Submitted by: Pierre Labastie 2 | Date: 2020-05-10 3 | Initial Package Version: 1.20.7 4 | Origin: Upstream + PR's 5 | Upstream Status: some fixes committed, others pending 6 | Description: Fix several build failures 7 | - some introduced by glibc-2.26 8 | - some introduced by gcc-10 9 | - also fix an ignored error when gpm.h is not already in 10 | /usr/include 11 | diff -Naur gpm-1.20.7.old/src/daemon/open_console.c gpm-1.20.7.new/src/daemon/open_console.c 12 | --- gpm-1.20.7.old/src/daemon/open_console.c 2012-10-26 23:21:38.000000000 +0200 13 | +++ gpm-1.20.7.new/src/daemon/open_console.c 2020-05-10 15:48:59.752067421 +0200 14 | @@ -23,6 +23,10 @@ 15 | #include /* stat() */ 16 | #include /* ioctl */ 17 | 18 | +#ifdef HAVE_SYS_SYSMACROS_H 19 | +#include /* major() w/newer glibc */ 20 | +#endif 21 | + 22 | /* Linux specific (to be outsourced in gpm2 */ 23 | #include /* for serial console check */ 24 | #include /* for serial console check */ 25 | diff -Naur gpm-1.20.7.old/src/headers/daemon.h gpm-1.20.7.new/src/headers/daemon.h 26 | --- gpm-1.20.7.old/src/headers/daemon.h 2012-10-26 23:21:38.000000000 +0200 27 | +++ gpm-1.20.7.new/src/headers/daemon.h 2020-05-10 15:48:52.719159555 +0200 28 | @@ -180,7 +180,7 @@ 29 | extern Gpm_Type mice[]; 30 | extern Gpm_Type *repeated_type; 31 | 32 | -time_t last_selection_time; 33 | +extern time_t last_selection_time; 34 | 35 | 36 | 37 | diff -Naur gpm-1.20.7.old/src/prog/display-buttons.c gpm-1.20.7.new/src/prog/display-buttons.c 38 | --- gpm-1.20.7.old/src/prog/display-buttons.c 2012-10-26 23:21:38.000000000 +0200 39 | +++ gpm-1.20.7.new/src/prog/display-buttons.c 2020-05-10 15:48:59.751067434 +0200 40 | @@ -36,7 +36,7 @@ 41 | #include /* printf() */ 42 | #include /* time() */ 43 | #include /* errno */ 44 | -#include /* gpm information */ 45 | +#include "headers/gpm.h" /* gpm information */ 46 | 47 | /* display resulting data */ 48 | int display_data(Gpm_Event *event, void *data) 49 | diff -Naur gpm-1.20.7.old/src/prog/display-coords.c gpm-1.20.7.new/src/prog/display-coords.c 50 | --- gpm-1.20.7.old/src/prog/display-coords.c 2012-10-26 23:21:38.000000000 +0200 51 | +++ gpm-1.20.7.new/src/prog/display-coords.c 2020-05-10 15:48:59.751067434 +0200 52 | @@ -37,7 +37,7 @@ 53 | #include /* printf() */ 54 | #include /* time() */ 55 | #include /* errno */ 56 | -#include /* gpm information */ 57 | +#include "headers/gpm.h" /* gpm information */ 58 | 59 | /* display resulting data */ 60 | int display_data(Gpm_Event *event, void *data) 61 | diff -Naur gpm-1.20.7.old/src/prog/get-versions.c gpm-1.20.7.new/src/prog/get-versions.c 62 | --- gpm-1.20.7.old/src/prog/get-versions.c 2012-10-26 23:21:38.000000000 +0200 63 | +++ gpm-1.20.7.new/src/prog/get-versions.c 2020-05-10 15:48:59.751067434 +0200 64 | @@ -22,7 +22,7 @@ 65 | ********/ 66 | 67 | #include /* printf() */ 68 | -#include /* gpm information */ 69 | +#include "headers/gpm.h" /* gpm information */ 70 | 71 | int main() 72 | { 73 | diff -Naur gpm-1.20.7.old/src/prog/gpm-root.y gpm-1.20.7.new/src/prog/gpm-root.y 74 | --- gpm-1.20.7.old/src/prog/gpm-root.y 2012-10-26 23:21:38.000000000 +0200 75 | +++ gpm-1.20.7.new/src/prog/gpm-root.y 2020-05-10 15:48:59.752067421 +0200 76 | @@ -443,6 +443,7 @@ 77 | } 78 | 79 | /*---------------------------------------------------------------------*/ 80 | +#if 0 81 | static int f_debug_one(FILE *f, Draw *draw) 82 | { 83 | DrawItem *ip; 84 | @@ -465,6 +466,7 @@ 85 | #undef LINE 86 | return 0; 87 | } 88 | +#endif 89 | 90 | int f_debug(int mode, DrawItem *self, int uid) 91 | { 92 | @@ -960,10 +962,8 @@ 93 | /*------------*/ 94 | static inline void scr_restore(int fd, FILE *f, unsigned char *buffer, int vc) 95 | { 96 | - int x,y, dumpfd; 97 | + int dumpfd; 98 | char dumpname[20]; 99 | - 100 | - x=buffer[2]; y=buffer[3]; 101 | 102 | /* WILL NOT WORK WITH DEVFS! FIXME! */ 103 | sprintf(dumpname,"/dev/vcsa%i",vc); 104 | @@ -1196,11 +1196,7 @@ 105 | LOG_DAEMON : LOG_USER); 106 | /* reap your zombies */ 107 | childaction.sa_handler=reap_children; 108 | -#if defined(__GLIBC__) 109 | - __sigemptyset(&childaction.sa_mask); 110 | -#else /* __GLIBC__ */ 111 | - childaction.sa_mask=0; 112 | -#endif /* __GLIBC__ */ 113 | + sigemptyset(&childaction.sa_mask); 114 | childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */ 115 | sigaction(SIGCHLD,&childaction,NULL); 116 | 117 | -------------------------------------------------------------------------------- /patches/kbd-2.4.0-backspace-1.patch: -------------------------------------------------------------------------------- 1 | Submitted By: Matt Burgess 2 | Date: 2008-12-06 3 | Initial Package Version: 1.15 4 | Upstream Status: Not submitted, possibly incomplete 5 | Description: Makes Backspace and Delete keys consistent in all i386 keymaps. 6 | Makes the Backspace key send character code 127, and Delete send a well known 7 | escape sequence. Obsoletes the /etc/kbd/bs-sends-del file for i386. 8 | 9 | Original patch for 1.12 by Alexander Patrakov. 10 | Updated for 1.13 (drop ru.map, the change is upstream, and add ru_win.map, 11 | ru-cp1251.map) by Ken Moffat . 12 | Re-diffed against 1.15 by Matt Burgess . 13 | 14 | diff -Naur kbd-1.15.orig/data/keymaps/i386/dvorak/dvorak-l.map kbd-1.15/data/keymaps/i386/dvorak/dvorak-l.map 15 | --- kbd-1.15.orig/data/keymaps/i386/dvorak/dvorak-l.map 2008-06-20 12:36:01.000000000 +0100 16 | +++ kbd-1.15/data/keymaps/i386/dvorak/dvorak-l.map 2008-12-03 22:27:55.000000000 +0000 17 | @@ -43,7 +43,7 @@ 18 | keycode 11 = three numbersign 19 | keycode 12 = two at 20 | keycode 13 = one exclam 21 | - keycode 14 = BackSpace Delete 22 | + keycode 14 = Delete Delete 23 | ! -------------------------------------------------------------------------- 24 | ! Row 3 25 | ! -------------------------------------------------------------------------- 26 | diff -Naur kbd-1.15.orig/data/keymaps/i386/dvorak/dvorak-r.map kbd-1.15/data/keymaps/i386/dvorak/dvorak-r.map 27 | --- kbd-1.15.orig/data/keymaps/i386/dvorak/dvorak-r.map 2008-06-20 12:36:01.000000000 +0100 28 | +++ kbd-1.15/data/keymaps/i386/dvorak/dvorak-r.map 2008-12-03 22:28:13.000000000 +0000 29 | @@ -43,7 +43,7 @@ 30 | keycode 11 = slash question 31 | keycode 12 = bracketleft braceleft 32 | keycode 13 = bracketright braceright 33 | - keycode 14 = BackSpace Delete 34 | + keycode 14 = Delete Delete 35 | ! -------------------------------------------------------------------------- 36 | ! Row 3 37 | ! -------------------------------------------------------------------------- 38 | diff -Naur kbd-1.15.orig/data/keymaps/i386/fgGIod/tr_f-latin5.map kbd-1.15/data/keymaps/i386/fgGIod/tr_f-latin5.map 39 | --- kbd-1.15.orig/data/keymaps/i386/fgGIod/tr_f-latin5.map 2008-10-23 20:03:58.000000000 +0100 40 | +++ kbd-1.15/data/keymaps/i386/fgGIod/tr_f-latin5.map 2008-12-03 22:40:32.000000000 +0000 41 | @@ -51,7 +51,7 @@ 42 | alt keycode 12 = Meta_minus 43 | keycode 13 = minus underscore 44 | alt keycode 13 = Meta_equal 45 | -keycode 14 = BackSpace Delete 46 | +keycode 14 = Delete Delete 47 | alt keycode 14 = Meta_Delete 48 | keycode 15 = Tab Meta_Tab 49 | alt keycode 15 = Meta_Tab 50 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/lt.l4.map kbd-1.15/data/keymaps/i386/qwerty/lt.l4.map 51 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/lt.l4.map 2008-10-23 20:03:59.000000000 +0100 52 | +++ kbd-1.15/data/keymaps/i386/qwerty/lt.l4.map 2008-12-03 22:42:14.000000000 +0000 53 | @@ -205,7 +205,7 @@ 54 | # edit this if you want the key above to delete symbols above 55 | # cursor, not before. 56 | keycode 14 = \ 57 | - BackSpace BackSpace BackSpace BackSpace \ 58 | + Delete Delete Delete Delete \ 59 | Delete Delete Delete Delete \ 60 | Meta_BackSpace Meta_BackSpace Meta_BackSpace Meta_BackSpace \ 61 | Meta_Delete Meta_Delete Meta_Delete Meta_Delete 62 | @@ -506,7 +506,7 @@ 63 | 64 | # Edit this if you want strict VT100 emulation. 65 | string F111 = "\033[3$" 66 | -keycode 111 = Delete F111 Delete F111 \ 67 | +keycode 111 = Remove F111 Remove F111 \ 68 | Remove Remove Remove Remove \ 69 | Meta_Delete Meta_Delete Meta_Delete Meta_Delete \ 70 | Boot Boot Boot Boot 71 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/lt.map kbd-1.15/data/keymaps/i386/qwerty/lt.map 72 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/lt.map 2008-10-23 20:03:59.000000000 +0100 73 | +++ kbd-1.15/data/keymaps/i386/qwerty/lt.map 2008-12-03 22:42:58.000000000 +0000 74 | @@ -204,7 +204,7 @@ 75 | # edit this if you want the key above to delete symbols above 76 | # cursor, not before. 77 | keycode 14 = \ 78 | - BackSpace BackSpace BackSpace BackSpace \ 79 | + Delete Delete Delete Delete \ 80 | Delete Delete Delete Delete \ 81 | Meta_BackSpace Meta_BackSpace Meta_BackSpace Meta_BackSpace \ 82 | Meta_Delete Meta_Delete Meta_Delete Meta_Delete 83 | @@ -505,7 +505,7 @@ 84 | 85 | # Edit this if you want strict VT100 emulation. 86 | string F111 = "\033[3$" 87 | -keycode 111 = Delete F111 Delete F111 \ 88 | +keycode 111 = Remove F111 Remove F111 \ 89 | Remove Remove Remove Remove \ 90 | Meta_Delete Meta_Delete Meta_Delete Meta_Delete \ 91 | Boot Boot Boot Boot 92 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/no-latin1.map kbd-1.15/data/keymaps/i386/qwerty/no-latin1.map 93 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/no-latin1.map 2008-06-20 12:36:00.000000000 +0100 94 | +++ kbd-1.15/data/keymaps/i386/qwerty/no-latin1.map 2008-12-03 22:44:25.000000000 +0000 95 | @@ -3,7 +3,7 @@ 96 | # Send comments to Kjetil T. Homme 97 | include "linux-with-alt-and-altgr" 98 | plain keycode 83 = KP_Comma 99 | - plain keycode 111 = Delete # "Remove" originally, weird... 100 | + plain keycode 111 = Remove 101 | strings as usual 102 | 103 | keycode 1 = Escape 104 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ru1.map kbd-1.15/data/keymaps/i386/qwerty/ru1.map 105 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ru1.map 2008-10-23 20:03:59.000000000 +0100 106 | +++ kbd-1.15/data/keymaps/i386/qwerty/ru1.map 2008-12-03 22:45:32.000000000 +0000 107 | @@ -143,8 +143,8 @@ 108 | 109 | # The keycode "0xFF" is too dangerous for many programs (including emacs). 110 | # So let it be bracket instead of Hard Sign. 111 | -# altgr keycode 27 = +0xDF 112 | -# altgr shift keycode 27 = +0xFF 113 | +altgr keycode 27 = +0xDF 114 | +altgr shift keycode 27 = +0xFF 115 | control keycode 27 = Control_bracketright 116 | altgr control keycode 27 = Control_bracketright 117 | alt keycode 27 = Meta_bracketright 118 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ru2.map kbd-1.15/data/keymaps/i386/qwerty/ru2.map 119 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ru2.map 2008-10-23 20:03:59.000000000 +0100 120 | +++ kbd-1.15/data/keymaps/i386/qwerty/ru2.map 2008-12-03 22:46:15.000000000 +0000 121 | @@ -46,7 +46,7 @@ 122 | alt keycode 12 = Meta_minus 123 | keycode 13 = equal plus equal plus 124 | alt keycode 13 = Meta_equal 125 | - keycode 14 = BackSpace BackSpace BackSpace BackSpace 126 | + keycode 14 = Delete Delete Delete Delete 127 | alt keycode 14 = Meta_Delete 128 | keycode 15 = Tab Tab Tab Tab 129 | alt keycode 15 = Meta_Tab 130 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ru-cp1251.map kbd-1.15/data/keymaps/i386/qwerty/ru-cp1251.map 131 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ru-cp1251.map 2008-10-23 20:03:59.000000000 +0100 132 | +++ kbd-1.15/data/keymaps/i386/qwerty/ru-cp1251.map 2008-12-03 22:47:12.000000000 +0000 133 | @@ -39,7 +39,7 @@ 134 | alt keycode 12 = Meta_minus 135 | keycode 13 = equal plus equal plus 136 | alt keycode 13 = Meta_equal 137 | - keycode 14 = BackSpace 138 | + keycode 14 = Delete 139 | alt keycode 14 = Meta_Delete 140 | keycode 15 = Tab 141 | alt keycode 15 = Meta_Tab 142 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ru-ms.map kbd-1.15/data/keymaps/i386/qwerty/ru-ms.map 143 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ru-ms.map 2008-10-23 20:03:59.000000000 +0100 144 | +++ kbd-1.15/data/keymaps/i386/qwerty/ru-ms.map 2008-12-03 22:48:10.000000000 +0000 145 | @@ -89,8 +89,8 @@ 146 | altgr alt keycode 13 = Meta_equal 147 | shift alt keycode 13 = Meta_plus 148 | altgr shift alt keycode 13 = Meta_plus 149 | - keycode 14 = BackSpace BackSpace BackSpace BackSpace 150 | -# keycode 14 = Delete Delete Delete Delete 151 | +# keycode 14 = BackSpace BackSpace BackSpace BackSpace 152 | + keycode 14 = Delete Delete Delete Delete 153 | alt keycode 14 = Meta_Delete 154 | altgr alt keycode 14 = Meta_Delete 155 | keycode 15 = Tab Tab Tab Tab 156 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ru_win.map kbd-1.15/data/keymaps/i386/qwerty/ru_win.map 157 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ru_win.map 2008-10-23 20:03:59.000000000 +0100 158 | +++ kbd-1.15/data/keymaps/i386/qwerty/ru_win.map 2008-12-03 22:49:17.000000000 +0000 159 | @@ -42,7 +42,7 @@ 160 | alt keycode 12 = Meta_minus 161 | keycode 13 = equal plus equal plus 162 | alt keycode 13 = Meta_equal 163 | - keycode 14 = BackSpace BackSpace BackSpace BackSpace 164 | + keycode 14 = Delete Delete Delete Delete 165 | alt keycode 14 = Meta_Delete 166 | keycode 15 = Tab Tab Tab Tab 167 | alt keycode 15 = Meta_Tab 168 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/se-ir209.map kbd-1.15/data/keymaps/i386/qwerty/se-ir209.map 169 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/se-ir209.map 2008-10-23 20:03:59.000000000 +0100 170 | +++ kbd-1.15/data/keymaps/i386/qwerty/se-ir209.map 2008-12-03 22:50:18.000000000 +0000 171 | @@ -345,7 +345,7 @@ 172 | keycode 109 = Next Scroll_Forward 173 | keycode 110 = Insert 174 | 175 | - keycode 111 = Delete # "Remove" originally, weird... 176 | + keycode 111 = Remove 177 | control alt keycode 111 = Boot 178 | control altgr keycode 111 = Boot 179 | 180 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/se-lat6.map kbd-1.15/data/keymaps/i386/qwerty/se-lat6.map 181 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/se-lat6.map 2008-10-23 20:03:59.000000000 +0100 182 | +++ kbd-1.15/data/keymaps/i386/qwerty/se-lat6.map 2008-12-03 22:50:44.000000000 +0000 183 | @@ -374,6 +374,6 @@ 184 | keycode 109 = Next Scroll_Forward 185 | keycode 110 = Insert 186 | 187 | - keycode 111 = Delete # "Remove" originally, weird... 188 | + keycode 111 = Remove 189 | control alt keycode 111 = Boot 190 | control altgr keycode 111 = Boot 191 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/tr_q-latin5.map kbd-1.15/data/keymaps/i386/qwerty/tr_q-latin5.map 192 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/tr_q-latin5.map 2008-10-23 20:03:59.000000000 +0100 193 | +++ kbd-1.15/data/keymaps/i386/qwerty/tr_q-latin5.map 2008-12-03 22:52:09.000000000 +0000 194 | @@ -49,7 +49,7 @@ 195 | alt keycode 12 = Meta_minus 196 | keycode 13 = minus underscore 197 | alt keycode 13 = Meta_equal 198 | -keycode 14 = BackSpace Delete 199 | +keycode 14 = Delete Delete 200 | alt keycode 14 = Meta_Delete 201 | keycode 15 = Tab Meta_Tab 202 | alt keycode 15 = Meta_Tab 203 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ua.map kbd-1.15/data/keymaps/i386/qwerty/ua.map 204 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ua.map 2008-10-23 20:03:59.000000000 +0100 205 | +++ kbd-1.15/data/keymaps/i386/qwerty/ua.map 2008-12-03 22:52:52.000000000 +0000 206 | @@ -249,7 +249,7 @@ 207 | shift ctrll ctrlr keycode 13 = plus 208 | alt ctrll ctrlr keycode 13 = Meta_equal 209 | shift alt ctrll ctrlr keycode 13 = Meta_plus 210 | -keycode 14 = BackSpace Delete 211 | +keycode 14 = Delete Delete 212 | control keycode 14 = BackSpace 213 | alt keycode 14 = Meta_Delete 214 | ctrlr keycode 14 = BackSpace 215 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ua-utf.map kbd-1.15/data/keymaps/i386/qwerty/ua-utf.map 216 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ua-utf.map 2008-10-23 20:03:59.000000000 +0100 217 | +++ kbd-1.15/data/keymaps/i386/qwerty/ua-utf.map 2008-12-03 22:53:36.000000000 +0000 218 | @@ -250,7 +250,7 @@ 219 | shift ctrll ctrlr keycode 13 = plus 220 | alt ctrll ctrlr keycode 13 = Meta_equal 221 | shift alt ctrll ctrlr keycode 13 = Meta_plus 222 | -keycode 14 = BackSpace Delete 223 | +keycode 14 = Delete Delete 224 | control keycode 14 = BackSpace 225 | alt keycode 14 = Meta_Delete 226 | ctrlr keycode 14 = BackSpace 227 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ua-utf-ws.map kbd-1.15/data/keymaps/i386/qwerty/ua-utf-ws.map 228 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ua-utf-ws.map 2008-10-23 20:03:59.000000000 +0100 229 | +++ kbd-1.15/data/keymaps/i386/qwerty/ua-utf-ws.map 2008-12-03 22:54:06.000000000 +0000 230 | @@ -260,7 +260,7 @@ 231 | shift ctrll ctrlr keycode 13 = plus 232 | alt ctrll ctrlr keycode 13 = Meta_equal 233 | shift alt ctrll ctrlr keycode 13 = Meta_plus 234 | -keycode 14 = BackSpace Delete 235 | +keycode 14 = Delete Delete 236 | control keycode 14 = BackSpace 237 | alt keycode 14 = Meta_Delete 238 | ctrlr keycode 14 = BackSpace 239 | diff -Naur kbd-1.15.orig/data/keymaps/i386/qwerty/ua-ws.map kbd-1.15/data/keymaps/i386/qwerty/ua-ws.map 240 | --- kbd-1.15.orig/data/keymaps/i386/qwerty/ua-ws.map 2008-10-23 20:03:59.000000000 +0100 241 | +++ kbd-1.15/data/keymaps/i386/qwerty/ua-ws.map 2008-12-03 22:54:23.000000000 +0000 242 | @@ -260,7 +260,7 @@ 243 | shift ctrll ctrlr keycode 13 = plus 244 | alt ctrll ctrlr keycode 13 = Meta_equal 245 | shift alt ctrll ctrlr keycode 13 = Meta_plus 246 | -keycode 14 = BackSpace Delete 247 | +keycode 14 = Delete Delete 248 | control keycode 14 = BackSpace 249 | alt keycode 14 = Meta_Delete 250 | ctrlr keycode 14 = BackSpace 251 | -------------------------------------------------------------------------------- /patches/lua-5.4.4-shared_library-1.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp lua-5.4.4.orig/Makefile lua-5.4.4/Makefile 2 | --- lua-5.4.4.orig/Makefile 2021-11-04 16:25:27.000000000 +0000 3 | +++ lua-5.4.4/Makefile 2022-02-19 06:40:06.384545009 +0000 4 | @@ -52,7 +52,7 @@ R= $V.4 5 | all: $(PLAT) 6 | 7 | $(PLATS) help test clean: 8 | - @cd src && $(MAKE) $@ 9 | + @cd src && $(MAKE) $@ V=$(V) R=$(R) 10 | 11 | install: dummy 12 | cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) 13 | diff -Nurp lua-5.4.4.orig/src/Makefile lua-5.4.4/src/Makefile 14 | --- lua-5.4.4.orig/src/Makefile 2021-07-15 14:01:52.000000000 +0000 15 | +++ lua-5.4.4/src/Makefile 2022-02-19 06:40:36.918543726 +0000 16 | @@ -33,6 +33,7 @@ CMCFLAGS= 17 | PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris 18 | 19 | LUA_A= liblua.a 20 | +LUA_SO= liblua.so 21 | CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o 22 | LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o 23 | BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) 24 | @@ -44,7 +45,7 @@ LUAC_T= luac 25 | LUAC_O= luac.o 26 | 27 | ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) 28 | -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) 29 | +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO) 30 | ALL_A= $(LUA_A) 31 | 32 | # Targets start here. 33 | @@ -60,6 +61,12 @@ $(LUA_A): $(BASE_O) 34 | $(AR) $@ $(BASE_O) 35 | $(RANLIB) $@ 36 | 37 | +$(LUA_SO): $(CORE_O) $(LIB_O) 38 | + $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS) 39 | + ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V) 40 | + ln -sf $(LUA_SO).$(R) $(LUA_SO) 41 | + 42 | + 43 | $(LUA_T): $(LUA_O) $(LUA_A) 44 | $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) 45 | 46 | -------------------------------------------------------------------------------- /patches/nspr-4.32-add-loongarch64.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp nspr-4.32.orig/nspr/pr/include/md/_linux.cfg nspr-4.32/nspr/pr/include/md/_linux.cfg 2 | --- nspr-4.32.orig/nspr/pr/include/md/_linux.cfg 2021-06-30 21:43:23.000000000 +0000 3 | +++ nspr-4.32/nspr/pr/include/md/_linux.cfg 2021-08-21 07:19:27.994989645 +0000 4 | @@ -1255,6 +1255,52 @@ 5 | #define PR_BYTES_PER_WORD_LOG2 3 6 | #define PR_BYTES_PER_DWORD_LOG2 3 7 | 8 | +#elif defined(__loongarch_lp64) 9 | + 10 | +#undef IS_BIG_ENDIAN 11 | +#define IS_LITTLE_ENDIAN 1 12 | +#define IS_64 13 | + 14 | +#define PR_BYTES_PER_BYTE 1 15 | +#define PR_BYTES_PER_SHORT 2 16 | +#define PR_BYTES_PER_INT 4 17 | +#define PR_BYTES_PER_INT64 8 18 | +#define PR_BYTES_PER_LONG 8 19 | +#define PR_BYTES_PER_FLOAT 4 20 | +#define PR_BYTES_PER_DOUBLE 8 21 | +#define PR_BYTES_PER_WORD 8 22 | +#define PR_BYTES_PER_DWORD 8 23 | + 24 | +#define PR_BITS_PER_BYTE 8 25 | +#define PR_BITS_PER_SHORT 16 26 | +#define PR_BITS_PER_INT 32 27 | +#define PR_BITS_PER_INT64 64 28 | +#define PR_BITS_PER_LONG 64 29 | +#define PR_BITS_PER_FLOAT 32 30 | +#define PR_BITS_PER_DOUBLE 64 31 | +#define PR_BITS_PER_WORD 64 32 | + 33 | +#define PR_BITS_PER_BYTE_LOG2 3 34 | +#define PR_BITS_PER_SHORT_LOG2 4 35 | +#define PR_BITS_PER_INT_LOG2 5 36 | +#define PR_BITS_PER_INT64_LOG2 6 37 | +#define PR_BITS_PER_LONG_LOG2 6 38 | +#define PR_BITS_PER_FLOAT_LOG2 5 39 | +#define PR_BITS_PER_DOUBLE_LOG2 6 40 | +#define PR_BITS_PER_WORD_LOG2 6 41 | + 42 | +#define PR_ALIGN_OF_SHORT 2 43 | +#define PR_ALIGN_OF_INT 4 44 | +#define PR_ALIGN_OF_LONG 8 45 | +#define PR_ALIGN_OF_INT64 8 46 | +#define PR_ALIGN_OF_FLOAT 4 47 | +#define PR_ALIGN_OF_DOUBLE 8 48 | +#define PR_ALIGN_OF_POINTER 8 49 | +#define PR_ALIGN_OF_WORD 8 50 | + 51 | +#define PR_BYTES_PER_WORD_LOG2 3 52 | +#define PR_BYTES_PER_DWORD_LOG2 3 53 | + 54 | #else 55 | 56 | #error "Unknown CPU architecture" 57 | diff -Nurp nspr-4.32.orig/nspr/pr/include/md/_linux.h nspr-4.32/nspr/pr/include/md/_linux.h 58 | --- nspr-4.32.orig/nspr/pr/include/md/_linux.h 2021-06-30 21:43:23.000000000 +0000 59 | +++ nspr-4.32/nspr/pr/include/md/_linux.h 2021-08-21 07:11:42.295609366 +0000 60 | @@ -43,6 +43,8 @@ 61 | #define _PR_SI_ARCHITECTURE "arm" 62 | #elif defined(__aarch64__) 63 | #define _PR_SI_ARCHITECTURE "aarch64" 64 | +#elif defined(__loongarch_lp64) 65 | +#define _PR_SI_ARCHITECTURE "loongarch64" 66 | #elif defined(__hppa__) 67 | #define _PR_SI_ARCHITECTURE "hppa" 68 | #elif defined(__s390x__) 69 | -------------------------------------------------------------------------------- /patches/pyqt-5.15.6-cross_compiler.patch: -------------------------------------------------------------------------------- 1 | --- PyQt5-5.15.6.orig/configure.py 2021-10-29 14:11:33.366122700 +0000 2 | +++ PyQt5-5.15.6/configure.py 2022-02-12 10:09:57.544427874 +0000 3 | @@ -2438,7 +2438,7 @@ def run_test_program(mname, test, verbos 4 | 5 | # Create the output file, first making sure it doesn't exist. 6 | remove_file(out_file) 7 | - run_command(test + ' ' + out_file, verbose) 8 | + run_command('qemu-loongarch64' + ' ' + test + ' ' + out_file, verbose) 9 | 10 | if not os.access(out_file, os.F_OK): 11 | error("%s failed to create %s. Make sure your Qt installation is correct." % (test, out_file)) 12 | -------------------------------------------------------------------------------- /patches/pyqt-5.15.6-fix-sip.patch: -------------------------------------------------------------------------------- 1 | --- PyQt5-5.15.6.orig/sip/QtCore/QtCoremod.sip 2021-10-29 14:11:45.893837700 +0000 2 | +++ PyQt5-5.15.6/sip/QtCore/QtCoremod.sip 2022-02-12 10:13:36.547418672 +0000 3 | @@ -20,7 +20,7 @@ 4 | // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 5 | 6 | 7 | -%Module(name=PyQt5.QtCore, call_super_init=True, default_VirtualErrorHandler=PyQt5, keyword_arguments="Optional", use_limited_api=True, py_ssize_t_clean=True) 8 | +%Module(name=PyQt5.QtCore, call_super_init=True, default_VirtualErrorHandler=PyQt5, keyword_arguments="Optional", use_limited_api=True) 9 | 10 | %Timeline {Qt_5_0_0 Qt_5_0_1 Qt_5_0_2 Qt_5_1_0 Qt_5_1_1 Qt_5_2_0 Qt_5_2_1 Qt_5_3_0 Qt_5_3_1 Qt_5_3_2 Qt_5_4_0 Qt_5_4_1 Qt_5_4_2 Qt_5_5_0 Qt_5_5_1 Qt_5_6_0 Qt_5_6_1 Qt_5_6_2 Qt_5_6_3 Qt_5_6_4 Qt_5_6_5 Qt_5_6_6 Qt_5_6_7 Qt_5_6_8 Qt_5_6_9 Qt_5_7_0 Qt_5_7_1 Qt_5_8_0 Qt_5_8_1 Qt_5_9_0 Qt_5_9_1 Qt_5_9_2 Qt_5_9_3 Qt_5_9_4 Qt_5_9_5 Qt_5_9_6 Qt_5_9_7 Qt_5_9_8 Qt_5_9_9 Qt_5_10_0 Qt_5_10_1 Qt_5_11_0 Qt_5_11_1 Qt_5_11_2 Qt_5_11_3 Qt_5_12_0 Qt_5_12_1 Qt_5_12_2 Qt_5_12_3 Qt_5_12_4 Qt_5_13_0 Qt_5_14_0 Qt_5_15_0} 11 | 12 | -------------------------------------------------------------------------------- /patches/qt-everywhere-src-5.15.2-add-loongarch-config.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/common/g++-base.conf qt-everywhere-src-5.15.2/qtbase/mkspecs/common/g++-base.conf 2 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/common/g++-base.conf 2020-10-27 08:02:11.000000000 +0000 3 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/common/g++-base.conf 2022-01-11 11:50:11.052343928 +0000 4 | @@ -30,7 +30,7 @@ QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_ 5 | QMAKE_CFLAGS_GNUC99 = -std=gnu99 6 | QMAKE_CFLAGS_GNUC11 = -std=gnu11 7 | QMAKE_CXXFLAGS_CXX11 = -std=c++11 8 | -QMAKE_CXXFLAGS_CXX14 = -std=c++1y 9 | +QMAKE_CXXFLAGS_CXX14 = -std=c++1y -fpermissive 10 | QMAKE_CXXFLAGS_CXX1Z = -std=c++1z 11 | QMAKE_CXXFLAGS_CXX2A = -std=c++2a 12 | QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11 13 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/common/linux_loongarch_device_post.conf qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/common/linux_loongarch_device_post.conf 14 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/common/linux_loongarch_device_post.conf 1970-01-01 00:00:00.000000000 +0000 15 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/common/linux_loongarch_device_post.conf 2022-01-11 09:17:55.676950049 +0000 16 | @@ -0,0 +1 @@ 17 | +include(linux_device_post.conf) 18 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/loongarch64-generic-g++/qmake.conf qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/loongarch64-generic-g++/qmake.conf 19 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/loongarch64-generic-g++/qmake.conf 1970-01-01 00:00:00.000000000 +0000 20 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/loongarch64-generic-g++/qmake.conf 2022-01-11 09:17:24.427951362 +0000 21 | @@ -0,0 +1,9 @@ 22 | +# 23 | +# Generic qmake configuration for building with g++ on loongarch64 devices. 24 | +# 25 | +# A minimal configure line could look something like this: 26 | +# ./configure -device loongarch64-generic-g++ -device-option CROSS_COMPILE=loongarch64-unknown-linux-gnu- 27 | + 28 | +include(../common/linux_device_pre.conf) 29 | +include(../common/linux_loongarch_device_post.conf) 30 | +load(qt_config) 31 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/loongarch64-generic-g++/qplatformdefs.h qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/loongarch64-generic-g++/qplatformdefs.h 32 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/devices/loongarch64-generic-g++/qplatformdefs.h 1970-01-01 00:00:00.000000000 +0000 33 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/devices/loongarch64-generic-g++/qplatformdefs.h 2020-10-27 08:02:11.000000000 +0000 34 | @@ -0,0 +1,40 @@ 35 | +/**************************************************************************** 36 | +** 37 | +** Copyright (C) 2016 The Qt Company Ltd. 38 | +** Contact: https://www.qt.io/licensing/ 39 | +** 40 | +** This file is part of the qmake spec of the Qt Toolkit. 41 | +** 42 | +** $QT_BEGIN_LICENSE:LGPL$ 43 | +** Commercial License Usage 44 | +** Licensees holding valid commercial Qt licenses may use this file in 45 | +** accordance with the commercial license agreement provided with the 46 | +** Software or, alternatively, in accordance with the terms contained in 47 | +** a written agreement between you and The Qt Company. For licensing terms 48 | +** and conditions see https://www.qt.io/terms-conditions. For further 49 | +** information use the contact form at https://www.qt.io/contact-us. 50 | +** 51 | +** GNU Lesser General Public License Usage 52 | +** Alternatively, this file may be used under the terms of the GNU Lesser 53 | +** General Public License version 3 as published by the Free Software 54 | +** Foundation and appearing in the file LICENSE.LGPL3 included in the 55 | +** packaging of this file. Please review the following information to 56 | +** ensure the GNU Lesser General Public License version 3 requirements 57 | +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 58 | +** 59 | +** GNU General Public License Usage 60 | +** Alternatively, this file may be used under the terms of the GNU 61 | +** General Public License version 2.0 or (at your option) the GNU General 62 | +** Public license version 3 or any later version approved by the KDE Free 63 | +** Qt Foundation. The licenses are as published by the Free Software 64 | +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 65 | +** included in the packaging of this file. Please review the following 66 | +** information to ensure the GNU General Public License requirements will 67 | +** be met: https://www.gnu.org/licenses/gpl-2.0.html and 68 | +** https://www.gnu.org/licenses/gpl-3.0.html. 69 | +** 70 | +** $QT_END_LICENSE$ 71 | +** 72 | +****************************************************************************/ 73 | + 74 | +#include "../../linux-g++/qplatformdefs.h" 75 | --- qt-everywhere-src-5.15.2/qtbase/src/3rdparty/double-conversion/include/double-conversion/utils.h 2020-10-27 08:02:11.000000000 +0000 76 | +++ qt-everywhere-src-5.15.2.ok/qtbase/src/3rdparty/double-conversion/include/double-conversion/utils.h 2022-01-11 09:24:58.074710022 +0000 77 | @@ -93,6 +93,7 @@ int main(int argc, char** argv) { 78 | #if defined(_M_X64) || defined(__x86_64__) || \ 79 | defined(__ARMEL__) || defined(__avr32__) || defined(_M_ARM) || defined(_M_ARM64) || \ 80 | defined(__hppa__) || defined(__ia64__) || \ 81 | + defined(__loongarch__) || \ 82 | defined(__mips__) || \ 83 | defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \ 84 | defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \ 85 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/linux-loongarch64-gnu-g++/qmake.conf qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-loongarch64-gnu-g++/qmake.conf 86 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/linux-loongarch64-gnu-g++/qmake.conf 1970-01-01 00:00:00.000000000 +0000 87 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-loongarch64-gnu-g++/qmake.conf 2022-01-12 02:46:56.176083196 +0000 88 | @@ -0,0 +1,24 @@ 89 | +# 90 | +# qmake configuration for building with loongarch64-unknown-linux-gnu-g++ 91 | +# 92 | + 93 | +MAKEFILE_GENERATOR = UNIX 94 | +CONFIG += incremental 95 | +QMAKE_INCREMENTAL_STYLE = sublib 96 | + 97 | +include(../common/linux.conf) 98 | +include(../common/gcc-base-unix.conf) 99 | +include(../common/g++-unix.conf) 100 | + 101 | +# modifications to g++.conf 102 | +QMAKE_CC = loongarch64-unknown-linux-gnu-gcc 103 | +QMAKE_CXX = loongarch64-unknown-linux-gnu-g++ 104 | +QMAKE_LINK = loongarch64-unknown-linux-gnu-g++ 105 | +QMAKE_LINK_SHLIB = loongarch64-unknown-linux-gnu-g++ 106 | + 107 | +# modifications to linux.conf 108 | +QMAKE_AR = loongarch64-unknown-linux-gnu-ar cqs 109 | +QMAKE_OBJCOPY = loongarch64-unknown-linux-gnu-objcopy 110 | +QMAKE_NM = loongarch64-unknown-linux-gnu-nm -P 111 | +QMAKE_STRIP = loongarch64-unknown-linux-gnu-strip 112 | +load(qt_config) 113 | diff -Nurp qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/linux-loongarch64-gnu-g++/qplatformdefs.h qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-loongarch64-gnu-g++/qplatformdefs.h 114 | --- qt-everywhere-src-5.15.2.orig/qtbase/mkspecs/linux-loongarch64-gnu-g++/qplatformdefs.h 1970-01-01 00:00:00.000000000 +0000 115 | +++ qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-loongarch64-gnu-g++/qplatformdefs.h 2020-10-27 08:02:11.000000000 +0000 116 | @@ -0,0 +1,40 @@ 117 | +/**************************************************************************** 118 | +** 119 | +** Copyright (C) 2017 The Qt Company Ltd. 120 | +** Contact: https://www.qt.io/licensing/ 121 | +** 122 | +** This file is part of the qmake spec of the Qt Toolkit. 123 | +** 124 | +** $QT_BEGIN_LICENSE:LGPL$ 125 | +** Commercial License Usage 126 | +** Licensees holding valid commercial Qt licenses may use this file in 127 | +** accordance with the commercial license agreement provided with the 128 | +** Software or, alternatively, in accordance with the terms contained in 129 | +** a written agreement between you and The Qt Company. For licensing terms 130 | +** and conditions see https://www.qt.io/terms-conditions. For further 131 | +** information use the contact form at https://www.qt.io/contact-us. 132 | +** 133 | +** GNU Lesser General Public License Usage 134 | +** Alternatively, this file may be used under the terms of the GNU Lesser 135 | +** General Public License version 3 as published by the Free Software 136 | +** Foundation and appearing in the file LICENSE.LGPL3 included in the 137 | +** packaging of this file. Please review the following information to 138 | +** ensure the GNU Lesser General Public License version 3 requirements 139 | +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 140 | +** 141 | +** GNU General Public License Usage 142 | +** Alternatively, this file may be used under the terms of the GNU 143 | +** General Public License version 2.0 or (at your option) the GNU General 144 | +** Public license version 3 or any later version approved by the KDE Free 145 | +** Qt Foundation. The licenses are as published by the Free Software 146 | +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 147 | +** included in the packaging of this file. Please review the following 148 | +** information to ensure the GNU General Public License requirements will 149 | +** be met: https://www.gnu.org/licenses/gpl-2.0.html and 150 | +** https://www.gnu.org/licenses/gpl-3.0.html. 151 | +** 152 | +** $QT_END_LICENSE$ 153 | +** 154 | +****************************************************************************/ 155 | + 156 | +#include "../linux-g++/qplatformdefs.h" 157 | -------------------------------------------------------------------------------- /patches/sip-4.19.25-pyframe_getback.patch: -------------------------------------------------------------------------------- 1 | diff --git a/siplib/siplib.c b/siplib/siplib.c 2 | index db52b68..8019e97 100644 3 | --- a/siplib/siplib.c 4 | +++ b/siplib/siplib.c 5 | @@ -13747,7 +13747,7 @@ static struct _frame *sip_api_get_frame(int depth) 6 | 7 | while (frame != NULL && depth > 0) 8 | { 9 | - frame = frame->f_back; 10 | + frame = PyFrame_GetBack(frame); 11 | --depth; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /patches/sip-add-loongarch64.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp sip-4.19.25.orig/specs/linux-loongarch64-gnu-g++ sip-4.19.25/specs/linux-loongarch64-gnu-g++ 2 | --- sip-4.19.25.orig/specs/linux-loongarch64-gnu-g++ 1970-01-01 00:00:00.000000000 +0000 3 | +++ sip-4.19.25/specs/linux-loongarch64-gnu-g++ 2022-02-12 03:02:14.296506167 +0000 4 | @@ -0,0 +1,90 @@ 5 | +# 6 | +# qmake configuration for linux-loongarch64-gnu-g++ 7 | +# 8 | + 9 | +MAKEFILE_GENERATOR = UNIX 10 | +TEMPLATE = app 11 | +CONFIG += qt warn_on release incremental link_prl 12 | +QT += core gui 13 | +QMAKE_INCREMENTAL_STYLE = sublib 14 | + 15 | +QMAKE_CC = loongarch64-unknown-linux-gnu-gcc 16 | +QMAKE_LEX = flex 17 | +QMAKE_LEXFLAGS = 18 | +QMAKE_YACC = yacc 19 | +QMAKE_YACCFLAGS = -d 20 | +QMAKE_YACCFLAGS_MANGLE = -p $base -b $base 21 | +QMAKE_YACC_HEADER = $base.tab.h 22 | +QMAKE_YACC_SOURCE = $base.tab.c 23 | +QMAKE_CFLAGS = -pipe 24 | +QMAKE_CFLAGS_DEPS = -M 25 | +QMAKE_CFLAGS_WARN_ON = -Wall -W 26 | +QMAKE_CFLAGS_WARN_OFF = -w 27 | +QMAKE_CFLAGS_RELEASE = -O2 28 | +QMAKE_CFLAGS_DEBUG = -g 29 | +QMAKE_CFLAGS_SHLIB = -fPIC 30 | +QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses 31 | +QMAKE_CFLAGS_THREAD = -D_REENTRANT 32 | +QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden 33 | + 34 | +QMAKE_CXX = loongarch64-unknown-linux-gnu-g++ 35 | +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -fno-exceptions -fno-rtti 36 | +QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS 37 | +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON 38 | +QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF 39 | +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE 40 | +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG 41 | +QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB 42 | +QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC 43 | +QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD 44 | +QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden 45 | + 46 | +QMAKE_INCDIR = 47 | +QMAKE_LIBDIR = 48 | +QMAKE_INCDIR_X11 = 49 | +QMAKE_LIBDIR_X11 = 50 | +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] 51 | +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] 52 | +QMAKE_INCDIR_OPENGL = 53 | +QMAKE_LIBDIR_OPENGL = 54 | + 55 | +QMAKE_LINK = loongarch64-unknown-linux-gnu-g++ 56 | +QMAKE_LINK_SHLIB = loongarch64-unknown-linux-gnu-g++ 57 | +QMAKE_LFLAGS = 58 | +QMAKE_LFLAGS_RELEASE = 59 | +QMAKE_LFLAGS_DEBUG = 60 | +QMAKE_LFLAGS_SHLIB = -shared 61 | +QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB 62 | +QMAKE_LFLAGS_SONAME = -Wl,-soname, 63 | +QMAKE_LFLAGS_THREAD = 64 | +QMAKE_RPATH = -Wl,-rpath, 65 | + 66 | +QMAKE_LIBS = 67 | +QMAKE_LIBS_DYNLOAD = -ldl 68 | +QMAKE_LIBS_X11 = 69 | +QMAKE_LIBS_X11SM = 70 | +QMAKE_LIBS_NIS = -lnsl 71 | +QMAKE_LIBS_OPENGL = 72 | +QMAKE_LIBS_OPENGL_QT = 73 | +QMAKE_LIBS_THREAD = -lpthread 74 | + 75 | +QMAKE_MOC = $$[QT_INSTALL_BINS]/moc 76 | +QMAKE_UIC = $$[QT_INSTALL_BINS]/uic 77 | + 78 | +QMAKE_AR = loongarch64-unknown-linux-gnu-ar cqs 79 | +QMAKE_RANLIB = 80 | + 81 | +QMAKE_TAR = tar -cf 82 | +QMAKE_GZIP = gzip -9f 83 | + 84 | +QMAKE_COPY = cp -f 85 | +QMAKE_COPY_FILE = $(COPY) 86 | +QMAKE_COPY_DIR = $(COPY) -r 87 | +QMAKE_MOVE = mv -f 88 | +QMAKE_DEL_FILE = rm -f 89 | +QMAKE_DEL_DIR = rmdir 90 | +QMAKE_STRIP = loongarch64-unknown-linux-gnu-strip 91 | +QMAKE_STRIPFLAGS_LIB += --strip-unneeded 92 | +QMAKE_CHK_DIR_EXISTS = test -d 93 | +QMAKE_MKDIR = mkdir -p 94 | +load(qt_config) 95 | -------------------------------------------------------------------------------- /patches/stack-direction-add-loongarch.patch: -------------------------------------------------------------------------------- 1 | From 34add045fd2ec3f1031dee961c4d9cc4285486a7 Mon Sep 17 00:00:00 2001 2 | From: Sun Haiyong 3 | Date: Tue, 31 Aug 2021 11:11:52 +0800 4 | Subject: [PATCH] stack-direction: Add support for loongarch CPU 5 | 6 | * m4/stack-direction.m4 (SV_STACK_DIRECTION): When the CPU is loongarch, 7 | set "sv_cv_stack_direction" to "-1" . 8 | --- 9 | m4/stack-direction.m4 | 1 + 10 | 1 file changed, 1 insertion(+) 11 | 12 | diff --git a/m4/stack-direction.m4 b/m4/stack-direction.m4 13 | index 93287254b..e6c3284ce 100644 14 | --- a/m4/stack-direction.m4 15 | +++ b/m4/stack-direction.m4 16 | @@ -32,6 +32,7 @@ AC_DEFUN([SV_STACK_DIRECTION], 17 | i?86 | x86_64 | \ 18 | i860 | \ 19 | ia64 | \ 20 | + loongarch* | \ 21 | m32r | \ 22 | m68* | \ 23 | m88k | \ 24 | -- 25 | 2.17.2 26 | 27 | -------------------------------------------------------------------------------- /patches/userspace-rcu-0.13.1-add-loongarch64.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp userspace-rcu-0.13.1.orig/include/urcu/arch/loongarch64.h userspace-rcu-0.13.1/include/urcu/arch/loongarch64.h 2 | --- userspace-rcu-0.13.1.orig/include/urcu/arch/loongarch64.h 1970-01-01 00:00:00.000000000 +0000 3 | +++ userspace-rcu-0.13.1/include/urcu/arch/loongarch64.h 2022-04-21 10:34:32.212507373 +0000 4 | @@ -0,0 +1,34 @@ 5 | +#ifndef _URCU_ARCH_LOONGARCH64_H 6 | +#define _URCU_ARCH_LOONGARCH64_H 7 | + 8 | +/* 9 | + * arch/loongarch64.h: definitions for the LoongArch64 architecture 10 | + * 11 | + */ 12 | + 13 | +#include 14 | +#include 15 | +#include 16 | + 17 | +#ifdef __cplusplus 18 | +extern "C" { 19 | +#endif 20 | + 21 | +#include 22 | +#include 23 | + 24 | +/* 25 | + * On Linux, define the membarrier system call number if not yet available in 26 | + * the system headers. 27 | + */ 28 | +#if (defined(__linux__) && !defined(__NR_membarrier)) 29 | +#define __NR_membarrier 283 30 | +#endif 31 | + 32 | +#ifdef __cplusplus 33 | +} 34 | +#endif 35 | + 36 | +#include 37 | + 38 | +#endif /* _URCU_ARCH_LOONGARCH64_H */ 39 | diff -Nurp userspace-rcu-0.13.1.orig/include/urcu/arch.h userspace-rcu-0.13.1/include/urcu/arch.h 40 | --- userspace-rcu-0.13.1.orig/include/urcu/arch.h 2022-01-05 20:38:11.000000000 +0000 41 | +++ userspace-rcu-0.13.1/include/urcu/arch.h 2022-04-21 10:32:24.745512729 +0000 42 | @@ -167,6 +167,11 @@ 43 | #define URCU_ARCH_RISCV 1 44 | #include 45 | 46 | +#elif defined(__loongarch_lp64) 47 | + 48 | +#define URCU_ARCH_LOONGARCH64 1 49 | +#include 50 | + 51 | #else 52 | #error "Cannot build: unrecognized architecture, see ." 53 | #endif 54 | diff -Nurp userspace-rcu-0.13.1.orig/include/urcu/uatomic/loongarch64.h userspace-rcu-0.13.1/include/urcu/uatomic/loongarch64.h 55 | --- userspace-rcu-0.13.1.orig/include/urcu/uatomic/loongarch64.h 1970-01-01 00:00:00.000000000 +0000 56 | +++ userspace-rcu-0.13.1/include/urcu/uatomic/loongarch64.h 2022-04-21 10:36:45.207501785 +0000 57 | @@ -0,0 +1,20 @@ 58 | +#ifndef _URCU_ARCH_UATOMIC_LOONGARCH64_H 59 | +#define _URCU_ARCH_UATOMIC_LOONGARCH64_H 60 | + 61 | +#include 62 | +#include 63 | + 64 | +#ifdef __cplusplus 65 | +extern "C" { 66 | +#endif 67 | + 68 | +#define UATOMIC_HAS_ATOMIC_BYTE 69 | +#define UATOMIC_HAS_ATOMIC_SHORT 70 | + 71 | +#ifdef __cplusplus 72 | +} 73 | +#endif 74 | + 75 | +#include 76 | + 77 | +#endif /* _URCU_ARCH_UATOMIC_LOONGARCH64_H */ 78 | diff -Nurp userspace-rcu-0.13.1.orig/include/urcu/uatomic.h userspace-rcu-0.13.1/include/urcu/uatomic.h 79 | --- userspace-rcu-0.13.1.orig/include/urcu/uatomic.h 2022-01-05 20:38:11.000000000 +0000 80 | +++ userspace-rcu-0.13.1/include/urcu/uatomic.h 2022-04-21 10:35:01.391506147 +0000 81 | @@ -51,6 +51,8 @@ 82 | #include 83 | #elif defined(URCU_ARCH_RISCV) 84 | #include 85 | +#elif defined(URCU_ARCH_LOONGARCH64) 86 | +#include 87 | #else 88 | #error "Cannot build: unrecognized architecture, see ." 89 | #endif 90 | --- userspace-rcu-0.13.1.ok/include/Makefile.am 2022-01-05 20:38:11.000000000 +0000 91 | +++ userspace-rcu-0.13.1/include/Makefile.am 2022-04-21 11:09:50.474418370 +0000 92 | @@ -7,6 +7,7 @@ nobase_include_HEADERS = \ 93 | urcu/arch.h \ 94 | urcu/arch/hppa.h \ 95 | urcu/arch/ia64.h \ 96 | + urcu/arch/loongarch64.h \ 97 | urcu/arch/m68k.h \ 98 | urcu/arch/mips.h \ 99 | urcu/arch/nios2.h \ 100 | @@ -67,6 +68,7 @@ nobase_include_HEADERS = \ 101 | urcu/uatomic.h \ 102 | urcu/uatomic/hppa.h \ 103 | urcu/uatomic/ia64.h \ 104 | + urcu/uatomic/loongarch64.h \ 105 | urcu/uatomic/m68k.h \ 106 | urcu/uatomic/mips.h \ 107 | urcu/uatomic/nios2.h \ 108 | -------------------------------------------------------------------------------- /patches/wireless_tools-29-fix_iwlist_scanning-1.patch: -------------------------------------------------------------------------------- 1 | Submitted By: Munir Contractor 2 | Date: 2016-09-03 3 | Initial Package Version: 29 4 | Upstream Status: From Upstream 5 | Origin: Arch Linux https://bugs.archlinux.org/task/15363 6 | Description: This patch fixes an issue where iwlist scan is not able to print the 7 | wireless network names if there are too many networks due to buffer 8 | allocation exceeding 65536. 9 | 10 | 11 | diff -Naur wireless_tools.29.orig/iwlist.c wireless_tools.29/iwlist.c 12 | --- wireless_tools.29.orig/iwlist.c 2007-06-30 01:11:09.000000000 +0000 13 | +++ wireless_tools.29/iwlist.c 2016-09-03 17:51:56.703353035 +0000 14 | @@ -799,7 +799,7 @@ 15 | if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0) 16 | { 17 | /* Check if buffer was too small (WE-17 only) */ 18 | - if((errno == E2BIG) && (range.we_version_compiled > 16)) 19 | + if((errno == E2BIG) && (range.we_version_compiled > 16) && (buflen < 65535)) 20 | { 21 | /* Some driver may return very large scan results, either 22 | * because there are many cells, or because they have many 23 | @@ -815,6 +815,9 @@ 24 | else 25 | buflen *= 2; 26 | 27 | + if(buflen > 65535) 28 | + buflen = 65535; 29 | + 30 | /* Try again */ 31 | goto realloc; 32 | } 33 | -------------------------------------------------------------------------------- /patches/xf86-video-ati-19.1.0-upstream_fixes-1.patch: -------------------------------------------------------------------------------- 1 | Submitted By: Douglas R. Reno 2 | Date: 2021-08-11 3 | Initial Package Version: 19.1.0 4 | Upstream Status: Applied 5 | Origin: Upstream commits after 19.1.0 release. 6 | Description: Fixes several performance regressions on some ATI 7 | graphics cards. Also rolls the fix for compiling 8 | with GCC-10 into the source tree, and adapts the 9 | driver to build with the next minor version of 10 | Xorg-Server (anything that uses master/slave terms 11 | will fail to build). On a SysV machine with an ATI 12 | card, this nets a 4x speed improvement, and the 13 | capability of running GNOME and KDE Plasma without 14 | problems. 15 | 16 | diff -Naurp xf86-video-ati-19.1.0.orig/man/radeon.man xf86-video-ati-19.1.0/man/radeon.man 17 | --- xf86-video-ati-19.1.0.orig/man/radeon.man 2019-10-15 11:16:29.000000000 -0500 18 | +++ xf86-video-ati-19.1.0/man/radeon.man 2021-07-29 16:27:10.685285445 -0500 19 | @@ -290,7 +290,7 @@ on. If this option is set, the default v 20 | accordingly. If this option isn't set, the default value of the property is 21 | .B auto, 22 | which means that TearFree is on for rotated outputs, outputs with RandR 23 | -transforms applied and for RandR 1.4 slave outputs, otherwise off. 24 | +transforms applied and for RandR 1.4 secondary outputs, otherwise off. 25 | .TP 26 | .BI "Option \*qAccelMethod\*q \*q" "string" \*q 27 | Chooses between available acceleration architectures. Valid values are 28 | diff -Naurp xf86-video-ati-19.1.0.orig/src/compat-api.h xf86-video-ati-19.1.0/src/compat-api.h 29 | --- xf86-video-ati-19.1.0.orig/src/compat-api.h 2019-10-15 11:16:29.000000000 -0500 30 | +++ xf86-video-ati-19.1.0/src/compat-api.h 2021-07-29 16:27:49.721971221 -0500 31 | @@ -34,4 +34,10 @@ 32 | #define BLOCKHANDLER_ARGS pScreen, pTimeout, pReadmask 33 | #endif 34 | 35 | +#if ABI_VIDEODRV_VERSION < SET_ABI_VERSION(25, 2) 36 | +#define current_primary current_master 37 | +#define primary_pixmap master_pixmap 38 | +#define secondary_dst slave_dst 39 | +#endif 40 | + 41 | #endif 42 | diff -Naurp xf86-video-ati-19.1.0.orig/src/drmmode_display.c xf86-video-ati-19.1.0/src/drmmode_display.c 43 | --- xf86-video-ati-19.1.0.orig/src/drmmode_display.c 2019-10-15 11:16:29.000000000 -0500 44 | +++ xf86-video-ati-19.1.0/src/drmmode_display.c 2021-07-29 16:40:03.226063398 -0500 45 | @@ -45,7 +45,9 @@ 46 | #include "radeon_glamor.h" 47 | #include "radeon_reg.h" 48 | 49 | +#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,19,99,1,0) 50 | #include 51 | +#endif 52 | 53 | #include "drmmode_display.h" 54 | 55 | @@ -720,7 +722,7 @@ drmmode_crtc_prime_scanout_update(xf86Cr 56 | xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, 57 | ent) { 58 | if (radeon_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) { 59 | - dirty->slave_dst = 60 | + dirty->secondary_dst = 61 | drmmode_crtc->scanout[scanout_id].pixmap; 62 | break; 63 | } 64 | @@ -1275,7 +1277,7 @@ drmmode_show_cursor (xf86CrtcPtr crtc) 65 | arg.hot_y = yhot; 66 | 67 | ret = drmIoctl(pRADEONEnt->fd, DRM_IOCTL_MODE_CURSOR2, &arg); 68 | - if (ret == -EINVAL) 69 | + if (ret == -1 && errno == EINVAL) 70 | use_set_cursor2 = FALSE; 71 | else 72 | return; 73 | @@ -1356,7 +1358,7 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr c 74 | 75 | xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) { 76 | if (radeon_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) { 77 | - PixmapStopDirtyTracking(dirty->src, dirty->slave_dst); 78 | + PixmapStopDirtyTracking(dirty->src, dirty->secondary_dst); 79 | break; 80 | } 81 | } 82 | diff -Naurp xf86-video-ati-19.1.0.orig/src/drmmode_display.h xf86-video-ati-19.1.0/src/drmmode_display.h 83 | --- xf86-video-ati-19.1.0.orig/src/drmmode_display.h 2019-10-15 11:16:29.000000000 -0500 84 | +++ xf86-video-ati-19.1.0/src/drmmode_display.h 2021-07-29 16:24:44.570461234 -0500 85 | @@ -262,7 +262,7 @@ Bool drmmode_wait_vblank(xf86CrtcPtr crt 86 | uint64_t *ust, uint32_t *result_seq); 87 | 88 | 89 | -miPointerSpriteFuncRec drmmode_sprite_funcs; 90 | +extern miPointerSpriteFuncRec drmmode_sprite_funcs; 91 | 92 | 93 | #endif 94 | diff -Naurp xf86-video-ati-19.1.0.orig/src/evergreen_state.h xf86-video-ati-19.1.0/src/evergreen_state.h 95 | --- xf86-video-ati-19.1.0.orig/src/evergreen_state.h 2019-10-15 11:16:29.000000000 -0500 96 | +++ xf86-video-ati-19.1.0/src/evergreen_state.h 2021-07-29 16:29:19.799246069 -0500 97 | @@ -350,7 +350,7 @@ extern void *RADEONEXACreatePixmap2(Scre 98 | int *new_pitch); 99 | extern void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv); 100 | extern Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix); 101 | -extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **handle_p); 102 | +extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr secondary, void **handle_p); 103 | extern Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *handle); 104 | 105 | #endif 106 | diff -Naurp xf86-video-ati-19.1.0.orig/src/r600_state.h xf86-video-ati-19.1.0/src/r600_state.h 107 | --- xf86-video-ati-19.1.0.orig/src/r600_state.h 2019-10-15 11:16:29.000000000 -0500 108 | +++ xf86-video-ati-19.1.0/src/r600_state.h 2021-07-29 16:29:36.132114565 -0500 109 | @@ -321,6 +321,6 @@ extern void *RADEONEXACreatePixmap2(Scre 110 | int *new_pitch); 111 | extern void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv); 112 | extern Bool RADEONEXAPixmapIsOffscreen(PixmapPtr pPix); 113 | -extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **handle_p); 114 | +extern Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr secondary, void **handle_p); 115 | extern Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *handle); 116 | #endif 117 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon_dri2.c xf86-video-ati-19.1.0/src/radeon_dri2.c 118 | --- xf86-video-ati-19.1.0.orig/src/radeon_dri2.c 2019-10-15 11:16:29.000000000 -0500 119 | +++ xf86-video-ati-19.1.0/src/radeon_dri2.c 2021-07-29 16:45:41.467337925 -0500 120 | @@ -729,7 +729,9 @@ radeon_dri2_exchange_buffers(DrawablePtr 121 | struct dri2_buffer_priv *front_priv = front->driverPrivate; 122 | struct dri2_buffer_priv *back_priv = back->driverPrivate; 123 | ScreenPtr screen = draw->pScreen; 124 | +#ifdef USE_GLAMOR 125 | RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); 126 | +#endif 127 | RegionRec region; 128 | int tmp; 129 | 130 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon_exa.c xf86-video-ati-19.1.0/src/radeon_exa.c 131 | --- xf86-video-ati-19.1.0.orig/src/radeon_exa.c 2019-10-15 11:16:29.000000000 -0500 132 | +++ xf86-video-ati-19.1.0/src/radeon_exa.c 2021-07-29 16:30:48.280533631 -0500 133 | @@ -282,7 +282,7 @@ void RADEONEXADestroyPixmap(ScreenPtr pS 134 | free(driverPriv); 135 | } 136 | 137 | -Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **fd_handle) 138 | +Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr secondary, void **fd_handle) 139 | { 140 | struct radeon_exa_pixmap_priv *driver_priv = exaGetPixmapDriverPrivate(ppix); 141 | 142 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon_glamor.c xf86-video-ati-19.1.0/src/radeon_glamor.c 143 | --- xf86-video-ati-19.1.0.orig/src/radeon_glamor.c 2019-10-15 11:16:29.000000000 -0500 144 | +++ xf86-video-ati-19.1.0/src/radeon_glamor.c 2021-07-29 16:31:05.112398098 -0500 145 | @@ -366,7 +366,7 @@ radeon_glamor_set_pixmap_bo(DrawablePtr 146 | 147 | 148 | static Bool 149 | -radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, 150 | +radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr secondary, 151 | void **handle_p) 152 | { 153 | ScreenPtr screen = pixmap->drawable.pScreen; 154 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon.h xf86-video-ati-19.1.0/src/radeon.h 155 | --- xf86-video-ati-19.1.0.orig/src/radeon.h 2019-10-15 11:16:29.000000000 -0500 156 | +++ xf86-video-ati-19.1.0/src/radeon.h 2021-07-29 16:30:34.626643574 -0500 157 | @@ -182,18 +182,18 @@ typedef enum { 158 | 159 | 160 | static inline ScreenPtr 161 | -radeon_master_screen(ScreenPtr screen) 162 | +radeon_primary_screen(ScreenPtr screen) 163 | { 164 | - if (screen->current_master) 165 | - return screen->current_master; 166 | + if (screen->current_primary) 167 | + return screen->current_primary; 168 | 169 | return screen; 170 | } 171 | 172 | static inline ScreenPtr 173 | -radeon_dirty_master(PixmapDirtyUpdatePtr dirty) 174 | +radeon_dirty_primary(PixmapDirtyUpdatePtr dirty) 175 | { 176 | - return radeon_master_screen(dirty->slave_dst->drawable.pScreen); 177 | + return radeon_primary_screen(dirty->secondary_dst->drawable.pScreen); 178 | } 179 | 180 | static inline DrawablePtr 181 | @@ -790,19 +790,18 @@ static inline Bool radeon_set_pixmap_bo( 182 | 183 | static inline struct radeon_buffer *radeon_get_pixmap_bo(PixmapPtr pPix) 184 | { 185 | -#ifdef USE_GLAMOR 186 | RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pPix->drawable.pScreen)); 187 | - 188 | +#ifdef USE_GLAMOR 189 | if (info->use_glamor) { 190 | struct radeon_pixmap *priv; 191 | priv = radeon_get_pixmap_private(pPix); 192 | return priv ? priv->bo : NULL; 193 | } else 194 | #endif 195 | - { 196 | - struct radeon_exa_pixmap_priv *driver_priv; 197 | - driver_priv = exaGetPixmapDriverPrivate(pPix); 198 | - return driver_priv ? driver_priv->bo : NULL; 199 | + if (info->accelOn) { 200 | + struct radeon_exa_pixmap_priv *driver_priv; 201 | + driver_priv = exaGetPixmapDriverPrivate(pPix); 202 | + return driver_priv ? driver_priv->bo : NULL; 203 | } 204 | 205 | return NULL; 206 | @@ -896,7 +895,7 @@ radeon_pixmap_get_fb(PixmapPtr pix) 207 | handle); 208 | } 209 | 210 | - return *fb_ptr; 211 | + return fb_ptr ? *fb_ptr : NULL; 212 | } 213 | 214 | 215 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon_kms.c xf86-video-ati-19.1.0/src/radeon_kms.c 216 | --- xf86-video-ati-19.1.0.orig/src/radeon_kms.c 2019-10-15 11:16:29.000000000 -0500 217 | +++ xf86-video-ati-19.1.0/src/radeon_kms.c 2021-07-29 16:37:14.531422523 -0500 218 | @@ -559,8 +559,8 @@ dirty_region(PixmapDirtyUpdatePtr dirty) 219 | if (dirty->rotation != RR_Rotate_0) { 220 | dstregion = transform_region(damageregion, 221 | &dirty->f_inverse, 222 | - dirty->slave_dst->drawable.width, 223 | - dirty->slave_dst->drawable.height); 224 | + dirty->secondary_dst->drawable.width, 225 | + dirty->secondary_dst->drawable.height); 226 | } else 227 | #endif 228 | { 229 | @@ -568,7 +568,7 @@ dirty_region(PixmapDirtyUpdatePtr dirty) 230 | 231 | dstregion = RegionDuplicate(damageregion); 232 | RegionTranslate(dstregion, -dirty->x, -dirty->y); 233 | - PixmapRegionInit(&pixregion, dirty->slave_dst); 234 | + PixmapRegionInit(&pixregion, dirty->secondary_dst); 235 | RegionIntersect(dstregion, dstregion, &pixregion); 236 | RegionUninit(&pixregion); 237 | } 238 | @@ -585,8 +585,8 @@ redisplay_dirty(PixmapDirtyUpdatePtr dir 239 | if (RegionNil(region)) 240 | goto out; 241 | 242 | - if (dirty->slave_dst->master_pixmap) 243 | - DamageRegionAppend(&dirty->slave_dst->drawable, region); 244 | + if (dirty->secondary_dst->primary_pixmap) 245 | + DamageRegionAppend(&dirty->secondary_dst->drawable, region); 246 | 247 | #ifdef HAS_DIRTYTRACKING_ROTATION 248 | PixmapSyncDirtyHelper(dirty); 249 | @@ -595,8 +595,8 @@ redisplay_dirty(PixmapDirtyUpdatePtr dir 250 | #endif 251 | 252 | radeon_cs_flush_indirect(src_scrn); 253 | - if (dirty->slave_dst->master_pixmap) 254 | - DamageRegionProcessPending(&dirty->slave_dst->drawable); 255 | + if (dirty->secondary_dst->primary_pixmap) 256 | + DamageRegionProcessPending(&dirty->secondary_dst->drawable); 257 | 258 | out: 259 | DamageEmpty(dirty->damage); 260 | @@ -613,12 +613,12 @@ radeon_prime_scanout_update_abort(xf86Cr 261 | void 262 | radeon_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty) 263 | { 264 | - ScreenPtr master_screen = radeon_dirty_master(dirty); 265 | + ScreenPtr primary_screen = radeon_dirty_primary(dirty); 266 | PixmapDirtyUpdatePtr ent; 267 | RegionPtr region; 268 | 269 | - xorg_list_for_each_entry(ent, &master_screen->pixmap_dirty_list, ent) { 270 | - if (!radeon_dirty_src_equals(dirty, ent->slave_dst)) 271 | + xorg_list_for_each_entry(ent, &primary_screen->pixmap_dirty_list, ent) { 272 | + if (!radeon_dirty_src_equals(dirty, ent->secondary_dst)) 273 | continue; 274 | 275 | region = dirty_region(ent); 276 | @@ -631,45 +631,45 @@ radeon_sync_shared_pixmap(PixmapDirtyUpd 277 | #if HAS_SYNC_SHARED_PIXMAP 278 | 279 | static Bool 280 | -master_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 281 | +primary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 282 | { 283 | - ScreenPtr master_screen = radeon_dirty_master(dirty); 284 | + ScreenPtr primary_screen = radeon_dirty_primary(dirty); 285 | 286 | - return !!master_screen->SyncSharedPixmap; 287 | + return !!primary_screen->SyncSharedPixmap; 288 | } 289 | 290 | static Bool 291 | -slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 292 | +secondary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 293 | { 294 | - ScreenPtr slave_screen = dirty->slave_dst->drawable.pScreen; 295 | + ScreenPtr secondary_screen = dirty->secondary_dst->drawable.pScreen; 296 | 297 | - return !!slave_screen->SyncSharedPixmap; 298 | + return !!secondary_screen->SyncSharedPixmap; 299 | } 300 | 301 | static void 302 | call_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty) 303 | { 304 | - ScreenPtr master_screen = radeon_dirty_master(dirty); 305 | + ScreenPtr primary_screen = radeon_dirty_primary(dirty); 306 | 307 | - master_screen->SyncSharedPixmap(dirty); 308 | + primary_screen->SyncSharedPixmap(dirty); 309 | } 310 | 311 | #else /* !HAS_SYNC_SHARED_PIXMAP */ 312 | 313 | static Bool 314 | -master_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 315 | +primary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 316 | { 317 | - ScrnInfoPtr master_scrn = xf86ScreenToScrn(radeon_dirty_master(dirty)); 318 | + ScrnInfoPtr primary_scrn = xf86ScreenToScrn(radeon_dirty_primary(dirty)); 319 | 320 | - return master_scrn->driverName == scrn->driverName; 321 | + return primary_scrn->driverName == scrn->driverName; 322 | } 323 | 324 | static Bool 325 | -slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 326 | +secondary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty) 327 | { 328 | - ScrnInfoPtr slave_scrn = xf86ScreenToScrn(dirty->slave_dst->drawable.pScreen); 329 | + ScrnInfoPtr secondary_scrn = xf86ScreenToScrn(dirty->secondary_dst->drawable.pScreen); 330 | 331 | - return slave_scrn->driverName == scrn->driverName; 332 | + return secondary_scrn->driverName == scrn->driverName; 333 | } 334 | 335 | static void 336 | @@ -684,12 +684,12 @@ call_sync_shared_pixmap(PixmapDirtyUpdat 337 | static xf86CrtcPtr 338 | radeon_prime_dirty_to_crtc(PixmapDirtyUpdatePtr dirty) 339 | { 340 | - ScreenPtr screen = dirty->slave_dst->drawable.pScreen; 341 | + ScreenPtr screen = dirty->secondary_dst->drawable.pScreen; 342 | ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 343 | xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); 344 | int c; 345 | 346 | - /* Find the CRTC which is scanning out from this slave pixmap */ 347 | + /* Find the CRTC which is scanning out from this secondary pixmap */ 348 | for (c = 0; c < xf86_config->num_crtc; c++) { 349 | xf86CrtcPtr xf86_crtc = xf86_config->crtc[c]; 350 | drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; 351 | @@ -714,7 +714,7 @@ radeon_prime_scanout_do_update(xf86CrtcP 352 | if (radeon_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) { 353 | RegionPtr region; 354 | 355 | - if (master_has_sync_shared_pixmap(scrn, dirty)) 356 | + if (primary_has_sync_shared_pixmap(scrn, dirty)) 357 | call_sync_shared_pixmap(dirty); 358 | 359 | region = dirty_region(dirty); 360 | @@ -727,7 +727,7 @@ radeon_prime_scanout_do_update(xf86CrtcP 361 | radeon_cs_flush_indirect(scrn); 362 | RegionCopy(&drmmode_crtc->scanout_last_region, region); 363 | RegionTranslate(region, -crtc->x, -crtc->y); 364 | - dirty->slave_dst = drmmode_crtc->scanout[scanout_id].pixmap; 365 | + dirty->secondary_dst = drmmode_crtc->scanout[scanout_id].pixmap; 366 | } 367 | 368 | redisplay_dirty(dirty, region); 369 | @@ -754,7 +754,7 @@ radeon_prime_scanout_update_handler(xf86 370 | static void 371 | radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty) 372 | { 373 | - ScreenPtr screen = dirty->slave_dst->drawable.pScreen; 374 | + ScreenPtr screen = dirty->secondary_dst->drawable.pScreen; 375 | ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 376 | RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn); 377 | xf86CrtcPtr xf86_crtc = radeon_prime_dirty_to_crtc(dirty); 378 | @@ -818,7 +818,7 @@ radeon_prime_scanout_update(PixmapDirtyU 379 | static void 380 | radeon_prime_scanout_flip(PixmapDirtyUpdatePtr ent) 381 | { 382 | - ScreenPtr screen = ent->slave_dst->drawable.pScreen; 383 | + ScreenPtr screen = ent->secondary_dst->drawable.pScreen; 384 | ScrnInfoPtr scrn = xf86ScreenToScrn(screen); 385 | RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn); 386 | xf86CrtcPtr crtc = radeon_prime_dirty_to_crtc(ent); 387 | @@ -893,11 +893,11 @@ radeon_dirty_update(ScrnInfoPtr scrn) 388 | if (screen->isGPU) { 389 | PixmapDirtyUpdatePtr region_ent = ent; 390 | 391 | - if (master_has_sync_shared_pixmap(scrn, ent)) { 392 | - ScreenPtr master_screen = radeon_dirty_master(ent); 393 | + if (primary_has_sync_shared_pixmap(scrn, ent)) { 394 | + ScreenPtr primary_screen = radeon_dirty_primary(ent); 395 | 396 | - xorg_list_for_each_entry(region_ent, &master_screen->pixmap_dirty_list, ent) { 397 | - if (radeon_dirty_src_equals(ent, region_ent->slave_dst)) 398 | + xorg_list_for_each_entry(region_ent, &primary_screen->pixmap_dirty_list, ent) { 399 | + if (radeon_dirty_src_equals(ent, region_ent->secondary_dst)) 400 | break; 401 | } 402 | } 403 | @@ -921,7 +921,7 @@ radeon_dirty_update(ScrnInfoPtr scrn) 404 | 405 | RegionDestroy(region); 406 | } else { 407 | - if (slave_has_sync_shared_pixmap(scrn, ent)) 408 | + if (secondary_has_sync_shared_pixmap(scrn, ent)) 409 | continue; 410 | 411 | region = dirty_region(ent); 412 | @@ -1216,7 +1216,7 @@ static void RADEONBlockHandler_KMS(BLOCK 413 | (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS); 414 | pScreen->BlockHandler = RADEONBlockHandler_KMS; 415 | 416 | - if (!xf86ScreenToScrn(radeon_master_screen(pScreen))->vtSema) 417 | + if (!xf86ScreenToScrn(radeon_primary_screen(pScreen))->vtSema) 418 | return; 419 | 420 | if (!pScreen->isGPU) 421 | @@ -2584,7 +2584,7 @@ CARD32 cleanup_black_fb(OsTimerPtr timer 422 | xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); 423 | int c; 424 | 425 | - if (xf86ScreenToScrn(radeon_master_screen(screen))->vtSema) 426 | + if (xf86ScreenToScrn(radeon_primary_screen(screen))->vtSema) 427 | return 0; 428 | 429 | /* Unreference the all-black FB created by RADEONLeaveVT_KMS. After 430 | diff -Naurp xf86-video-ati-19.1.0.orig/src/radeon_present.c xf86-video-ati-19.1.0/src/radeon_present.c 431 | --- xf86-video-ati-19.1.0.orig/src/radeon_present.c 2019-10-15 11:16:29.000000000 -0500 432 | +++ xf86-video-ati-19.1.0/src/radeon_present.c 2021-07-29 16:38:30.019814341 -0500 433 | @@ -254,7 +254,9 @@ radeon_present_check_flip(RRCrtcPtr crtc 434 | xf86CrtcPtr xf86_crtc = crtc->devPrivate; 435 | ScreenPtr screen = window->drawable.pScreen; 436 | ScrnInfoPtr scrn = xf86_crtc->scrn; 437 | +#ifdef USE_GLAMOR 438 | struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); 439 | +#endif 440 | xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); 441 | RADEONInfoPtr info = RADEONPTR(scrn); 442 | PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen); 443 | @@ -278,10 +280,13 @@ radeon_present_check_flip(RRCrtcPtr crtc 444 | return FALSE; 445 | #endif 446 | 447 | +#ifdef USE_GLAMOR 448 | if (priv && priv->fb_failed) 449 | return FALSE; 450 | +#endif 451 | 452 | if (!radeon_pixmap_get_fb(pixmap)) { 453 | +#ifdef USE_GLAMOR 454 | if (!priv) 455 | priv = radeon_get_pixmap_private(pixmap); 456 | 457 | @@ -291,6 +296,7 @@ radeon_present_check_flip(RRCrtcPtr crtc 458 | "normal if using PRIME render offloading)\n"); 459 | priv->fb_failed = TRUE; 460 | } 461 | +#endif 462 | 463 | return FALSE; 464 | } 465 | -------------------------------------------------------------------------------- /patches/xorg-server-21.1.3-fix-x11perf-segment-fault.patch: -------------------------------------------------------------------------------- 1 | diff -Nurp xorg-server-21.1.3.orig/render/picture.c xorg-server-21.1.3/render/picture.c 2 | --- xorg-server-21.1.3.orig/render/picture.c 2022-01-02 22:41:56.000000000 +0000 3 | +++ xorg-server-21.1.3/render/picture.c 2022-03-11 07:34:21.945802767 +0000 4 | @@ -188,6 +188,10 @@ PictureCreateDefaultFormats(ScreenPtr pS 5 | PICT_TYPE_A, 8, 0, 0, 0); 6 | formats[nformats].depth = 8; 7 | nformats++; 8 | + formats[nformats].format = PICT_FORMAT(BitsPerPixel(4), 9 | + PICT_TYPE_A, 4, 0, 0, 0); 10 | + formats[nformats].depth = 4; 11 | + nformats++; 12 | formats[nformats].format = PICT_a8r8g8b8; 13 | formats[nformats].depth = 32; 14 | nformats++; 15 | --------------------------------------------------------------------------------