diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce9a284 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/glibc/ +/patchelf/ diff --git a/README.md b/README.md deleted file mode 100644 index 7cd63ad..0000000 --- a/README.md +++ /dev/null @@ -1,47 +0,0 @@ -libLoL -====== - -简体中文自述文档请见[此处](README.zh.md) - -libLoL (LoongArch on LoongArch) is a compatibility runtime for applications -designed for LoongArch's old-world ABI. By and large, these are applications -built for Loongson's Loongnix reference Linux distribution and UnionTech's -UOS, consisting mostly commercial applications designed for the mainland -Chinese market, such as: - -- Tencent's QQ for Linux -- Kingsoft's WPS for Linux -- Loongson Browser (based on Chromium) - -As these applications have not yet been ported to the new-world ABI, this -runtime is meant to provide help users of new-world Linux distributions use -the aforementioned applications. - -For a brief introduction on old-world and new-world incompatibility, please -refer to [this essay](https://areweloongyet.com/docs/old-and-new-worlds/) (in -Chinese) from the Loongson Open Source Community's *Are We Loong Yet?* site. - -Components ----------- - -libLoL consists of two components, one in the kernel-space and the other in -the user-space. - -- Kernel: The [la_ow_syscall](https://github.com/AOSC-Dev/la_ow_syscall) - modules provides support for old-world system call support in the Linux - Kernel, making it possible to run old-world applications on new-world - (upstream) kernels. -- User-space: A [patched Glibc](https://github.com/AOSC-Dev/glibc-loongarch-oldworld) - provides symbol support for old-world applications - see the Autobuild - building procedure in this repository. Additional runtime may be provided - by the distribution or in binary form from [Loongnix](https://www.loongson.cn/system/loongnix). - -Reporting Issues ----------------- - -Please use the [Issues](https://github.com/AOSC-Dev/liblol/issues) function -for reporting any developer or user issues (feel free to use English or -Chinese). - -You are also welcome to report issues at AOSC's various -[chat groups](https://aosc.io/contact/). diff --git a/README.zh.md b/README.zh.md deleted file mode 100644 index 11305e7..0000000 --- a/README.zh.md +++ /dev/null @@ -1,23 +0,0 @@ -libLoL -====== - -libLoL (LoongArch on LoongArch) 是一款用于提供旧世界 ABI 兼容性的运行时。旧世界 ABI 常用于为龙芯官方的 Loongnix 参考发行和统信 UOS 设计的商业软件,如: - -- 腾讯 QQ Linux 版 -- 金山 WPS for Linux -- 龙芯浏览器(基于 Chromium) - -由于这些应用程序尚未移植到新世界 ABI 上,本运行时旨在为新世界发行版用户提供运行上述应用程序的便利。欲知有关新旧世界应用不兼容来由的相关信息,请见龙芯开源社区《咱龙了吗?》站点的[《新世界与旧世界》](https://areweloongyet.com/docs/old-and-new-worlds/)一文。 - -组件 ----- - -libLoL 由内核空间和用户空间两个组件组成: - -- 内核部分:通过 [la_ow_syscall](https://github.com/AOSC-Dev/la_ow_syscall) 模块,给 Linux 内核新增旧世界系统调用支持,进而使得新世界内核得以兼容旧世界运行时和应用程序 -- 用户空间部分:给 [Glibc 打补丁](https://github.com/AOSC-Dev/glibc-loongarch-oldworld)以提供旧世界应用程序所需符号的兼容性。其余运行时库由发行版软件包或 [Loongnix](https://www.loongson.cn/system/loongnix) 的二进制软件包提供。 - -报告问题 --------- - -请使用本仓库的[工单系统](https://github.com/AOSC-Dev/liblol/issues) 报告有关开发和使用方面的问题。您也可以通过我社的[聊天群组](https://aosc.io/zh-cn/contact/)报告问题。 diff --git a/autobuild/additional-files/hooks/postinst.in b/autobuild/additional-files/hooks/postinst.in deleted file mode 100644 index 13a7db0..0000000 --- a/autobuild/additional-files/hooks/postinst.in +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e -o pipefail - -if ! systemd-detect-virt --container >/dev/null ; then - echo "Loading the la_ow_syscall (old-world syscall compatibility) kernel module ..." - modprobe la_ow_syscall || \ - echo " -Warning: The la_ow_syscall kernel module does not appear to be available. -Old-world applications may not run. -" -fi diff --git a/autobuild/build b/autobuild/build deleted file mode 100644 index 278a334..0000000 --- a/autobuild/build +++ /dev/null @@ -1,222 +0,0 @@ -abinfo "Setting up build environment ..." -OWTARGET="loongarch64-aosc-linux-gnuow" -LOLPREFIX="/opt/lol" - -abinfo "Appending -O2 to CPPFLAGS to fix build ..." -export CPPFLAGS="${CPPFLAGS} -O2" - -apply_source_patch_series() { - local patch_path=$1 - local src_path=$2 - local package=$3 - local patch - - abinfo "Applying $package patches ..." - while IFS= read -r patch; do - abinfo " Applying $patch ..." - patch -p 1 --ignore-whitespace -d "$src_path" \ - < "$patch_path/$patch" - done <"$patch_path/series" -} - -glibc_source() { - abinfo "Extracting Glibc sources ..." - - abinfo "Setting up Glibc source tree ..." - abinfo "Unpacking Glibc source tar ..." - mkdir -pv "$BLDDIR/src/glibc" - tar \ - -C "$BLDDIR/src/glibc" \ - -xvJ \ - --strip-components=1 \ - -f "$SRCDIR/glibc.tar.xz" - apply_source_patch_series \ - "$SRCDIR/autobuild/patches/glibc" \ - "$BLDDIR/src/glibc" \ - "Glibc" -} - -glibc_build() { - mkdir -pv "$BLDDIR/build/glibc" - - pushd "$BLDDIR/build/glibc" - local cflags_common="-O2 -g -ffile-prefix-map=$BLDDIR=." - local ldflags_common="-Wl,-O1,--sort-common,--as-needed -Wl,-build-id=sha1" - - local debver=$PKGVER - if [ "$PKGREL" != 0 ]; then - debver+="-$PKGREL" - fi - - cat > configparms < "$SRCDIR/autobuild/$i" - chmod +x "$SRCDIR/autobuild/$i" - done -} - -abinfo "Building patchelf..." -patchelf_build - -abinfo "Building Glibc ..." -glibc_source -glibc_build - -abinfo "Making symlinks for system provided libs ..." -system_libs_prio=("/usr/lib/libstdc++.so.6") -for i in "${system_libs_prio[@]}"; do - ln -sfv "$i" "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/" -done - -abinfo "Installing package hooks ..." -install_hooks - -abinfo "Adding glibc dependency ..." -cur_glibc_version=$(dpkg-query -W --showformat='${Version}' glibc) -if [ -z "$cur_glibc_version" ]; then - abdie "Cannot find glibc version" -fi -abinfo "Current glibc version: $cur_glibc_version" -cur_glibc_epoch="" -if [[ "$cur_glibc_version" == *":"* ]]; then - cur_glibc_epoch="$(echo "$cur_glibc_version" | cut -d: -f1)" - abinfo "Current glibc epoch: $cur_glibc_epoch" - cur_glibc_epoch+=":" -fi -PKGDEP+=" glibc>=${cur_glibc_epoch}2.36 glibc<<${cur_glibc_epoch}${__GLIBC_VER}.1~" diff --git a/autobuild/defines b/autobuild/defines deleted file mode 100644 index c4986f3..0000000 --- a/autobuild/defines +++ /dev/null @@ -1,8 +0,0 @@ -PKGNAME=liblol -PKGSEC=utils -PKGDES="Compatibility layer for running applications designed for \"Old World\" LoongArch systems" - -NOLTO=1 - -FAIL_ARCH="!(loongarch64)" -BUILDDEP="" diff --git a/autobuild/overrides/usr/lib/modules-load.d/liblol.conf b/autobuild/overrides/usr/lib/modules-load.d/liblol.conf deleted file mode 100644 index 889d09d..0000000 --- a/autobuild/overrides/usr/lib/modules-load.d/liblol.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Load the la_ow_syscall kernel module for old-world compatibility. -la_ow_syscall diff --git a/autobuild/patch b/autobuild/patch deleted file mode 100644 index b9d207b..0000000 --- a/autobuild/patch +++ /dev/null @@ -1 +0,0 @@ -: "Do nothing" diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..5680fec --- /dev/null +++ b/debian/changelog @@ -0,0 +1,29 @@ +liblol (0.1.4-1) unstable; urgency=medium + + * Release 0.1.4-1 + + -- Miao Wang Fri, 01 Mar 2024 23:31:00 +0800 + +liblol (0.1.4~pre4-1) unstable; urgency=medium + + * glibc: also add syscall fallback for fstatat + + -- Miao Wang Tue, 20 Feb 2024 15:22:00 +0800 + +liblol (0.1.4~pre3-1) unstable; urgency=medium + + * make libc.so.6 executable + + -- Miao Wang Thu, 08 Feb 2024 16:09:00 +0800 + +liblol (0.1.4~pre2-1) unstable; urgency=medium + + * new upstream version + + -- Miao Wang Sun, 28 Jan 2024 08:07:00 +0800 + +liblol (0.1.3-1) unstable; urgency=medium + + * Initial upload + + -- Miao Wang Sat, 27 Jan 2024 18:09:00 +0800 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..9664a66 --- /dev/null +++ b/debian/control @@ -0,0 +1,26 @@ +Source: liblol +Section: otherosfs +Priority: optional +Maintainer: Miao Wang +Build-Depends: debhelper-compat (= 13), + libstdc++6, + quilt, + bison, + gawk, + python3, +Standards-Version: 4.6.2 +Homepage: https://github.com/AOSC-Dev/liblol + +Package: liblol +Architecture: loong64 +Multi-Arch: foreign +Depends: ${misc:Depends}, + ${shlibs:Depends}, + libstdc++6, + libc6 (>= 2.36), + libc6 (<< ${glibcVer}.1~), +Conflicts: glibc, +Recommends: liblol-dkms, +Description: Compatibility layer for old world applications + This package contains a Compatibility layer for old world + applications on new world loongarch64 platform. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..3cf73aa --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +/lib64/ +/usr/lib/loongarch64-debian-linux-gnuow diff --git a/autobuild/patches/glibc/0001-add-old-world-abi-compatibility.patch b/debian/patches/glibc/0001-add-old-world-abi-compatibility.patch similarity index 100% rename from autobuild/patches/glibc/0001-add-old-world-abi-compatibility.patch rename to debian/patches/glibc/0001-add-old-world-abi-compatibility.patch diff --git a/autobuild/patches/glibc/0002-add-sigset-ops.patch b/debian/patches/glibc/0002-add-sigset-ops.patch similarity index 100% rename from autobuild/patches/glibc/0002-add-sigset-ops.patch rename to debian/patches/glibc/0002-add-sigset-ops.patch diff --git a/autobuild/patches/glibc/0003-add-signal-functions.patch b/debian/patches/glibc/0003-add-signal-functions.patch similarity index 100% rename from autobuild/patches/glibc/0003-add-signal-functions.patch rename to debian/patches/glibc/0003-add-signal-functions.patch diff --git a/autobuild/patches/glibc/0004-add-sigaction-ucontext-compat.patch b/debian/patches/glibc/0004-add-sigaction-ucontext-compat.patch similarity index 100% rename from autobuild/patches/glibc/0004-add-sigaction-ucontext-compat.patch rename to debian/patches/glibc/0004-add-sigaction-ucontext-compat.patch diff --git a/autobuild/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch b/debian/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch similarity index 100% rename from autobuild/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch rename to debian/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch diff --git a/autobuild/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch b/debian/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch similarity index 100% rename from autobuild/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch rename to debian/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch diff --git a/autobuild/patches/glibc/0007-add-more-pthread-symbols.patch b/debian/patches/glibc/0007-add-more-pthread-symbols.patch similarity index 100% rename from autobuild/patches/glibc/0007-add-more-pthread-symbols.patch rename to debian/patches/glibc/0007-add-more-pthread-symbols.patch diff --git a/autobuild/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch b/debian/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch similarity index 100% rename from autobuild/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch rename to debian/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch diff --git a/autobuild/patches/glibc/0009-prepend-trusted-dirs.patch b/debian/patches/glibc/0009-prepend-trusted-dirs.patch similarity index 100% rename from autobuild/patches/glibc/0009-prepend-trusted-dirs.patch rename to debian/patches/glibc/0009-prepend-trusted-dirs.patch diff --git a/autobuild/patches/glibc/0010-Add-___brk_addr-symbol.patch b/debian/patches/glibc/0010-Add-___brk_addr-symbol.patch similarity index 100% rename from autobuild/patches/glibc/0010-Add-___brk_addr-symbol.patch rename to debian/patches/glibc/0010-Add-___brk_addr-symbol.patch diff --git a/debian/patches/glibc/local-ld-multiarch.diff b/debian/patches/glibc/local-ld-multiarch.diff new file mode 100644 index 0000000..0bf5db6 --- /dev/null +++ b/debian/patches/glibc/local-ld-multiarch.diff @@ -0,0 +1,51 @@ +2012-05-01 Aurelien Jarno + + * elf/Makefile(trusted-dirs.st): Fix DL_DST_LIB computation with + two level slibdir directories. + +2009-09-08 Aurelien Jarno + + * Makeconfig: add support for multiarch compat directories. + +--- + Makeconfig | 9 +++++++++ + elf/Makefile | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +--- a/Makeconfig ++++ b/Makeconfig +@@ -136,6 +136,11 @@ + endif + inst_libdir = $(install_root)$(libdir) + ++# Compat places to look for libraries ++ifndef extra_libdir ++extra_libdir = /lib:$(exec_prefix)/lib ++endif ++ + # Where to install the shared library. + ifndef slibdir + slibdir = $(exec_prefix)/lib +@@ -589,6 +594,10 @@ + default-rpath = $(libdir) + endif + ++ifdef extra_libdir ++default-rpath += :$(extra_libdir) ++endif ++ + ifndef link-extra-libs + link-extra-libs = $(LDLIBS-$(@F)) + link-extra-libs-static = $(link-extra-libs) +--- a/elf/Makefile ++++ b/elf/Makefile +@@ -507,7 +507,7 @@ + $(make-target-directory) + echo "$(subst :, ,$(user-defined-trusted-dirs-pre) $(default-rpath) $(user-defined-trusted-dirs))" \ + | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T}; +- echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T} ++ echo '#define DL_DST_LIB "$(shell echo $(slibdir) | sed 's,/,,')"' >> ${@:st=T} + echo '#define SYSTEM_DIRS_PRE_COUNT $(words $(subst :, ,$(user-defined-trusted-dirs-pre)))' >> ${@:st=T} + $(move-if-change) ${@:st=T} ${@:st=h} + touch $@ + CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx). diff --git a/debian/patches/glibc/local-remove-manual.diff b/debian/patches/glibc/local-remove-manual.diff new file mode 100644 index 0000000..e9ac85d --- /dev/null +++ b/debian/patches/glibc/local-remove-manual.diff @@ -0,0 +1,218 @@ +The GNU Libc Reference manual has to be removed for licensing reasons. +But some files have a dependency on manual/errno.texi; the easiest +solution is to drop those dependencies and make sure that MAKEINFO=: +so that no target depends on manual/*.texi files. + +--- + manual/Makefile | 182 +++++++++++++++++++++++++++++++++++++++++++++ + stdio-common/Makefile | 2 + sysdeps/mach/hurd/Makefile | 2 + 3 files changed, 184 insertions(+), 2 deletions(-) + +--- /dev/null ++++ b/manual/Makefile +@@ -0,0 +1,182 @@ ++# Copyright (C) 1992-2012 ++# Free Software Foundation, Inc. ++# This file is part of the GNU C Library. ++ ++# The GNU C Library is free software; you can redistribute it and/or ++# modify it under the terms of the GNU Lesser General Public ++# License as published by the Free Software Foundation; either ++# version 2.1 of the License, or (at your option) any later version. ++ ++# The GNU C Library is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# Lesser General Public License for more details. ++ ++# You should have received a copy of the GNU Lesser General Public ++# License along with the GNU C Library; if not, see ++# . ++ ++# Makefile for the GNU C Library manual. ++ ++subdir := manual ++ ++# Allow override ++INSTALL_INFO = install-info ++ ++.PHONY: dvi pdf info html ++ ++# Get glibc's configuration info. ++include ../Makeconfig ++ ++dvi: $(objpfx)libc.dvi ++pdf: $(objpfx)libc.pdf ++ ++TEXI2DVI = texi2dvi ++TEXI2PDF = texi2dvi --pdf ++ ++ifneq ($(strip $(MAKEINFO)),:) ++info: $(objpfx)libc.info ++endif ++ ++chapters = $(addsuffix .texi, \ ++ intro errno memory ctype string charset locale \ ++ message search pattern io stdio llio filesys \ ++ pipe socket terminal syslog math arith time \ ++ resource setjmp signal startup process job nss \ ++ users sysinfo conf crypt debug) ++add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi)) ++appendices = lang.texi header.texi install.texi maint.texi platform.texi \ ++ contrib.texi ++licenses = freemanuals.texi lgpl-2.1.texi fdl-1.3.texi ++ ++-include $(objpfx)texis ++$(objpfx)texis: texis.awk $(chapters) $(add-chapters) $(appendices) $(licenses) ++ $(make-target-directory) ++ $(AWK) -f $^ > $@.T ++ mv -f $@.T $@ ++ ++nonexamples = $(filter-out $(add-chapters) %.c.texi, $(texis)) ++examples = $(filter-out $(foreach d, $(add-ons), ../$d/%.c.texi), \ ++ $(filter %.c.texi, $(texis))) ++ ++# Generated files directly included from libc.texinfo. ++libc-texi-generated = chapters.texi top-menu.texi dir-add.texi \ ++ libm-err.texi version.texi ++ ++# Add path to build dir for generated files ++texis-path := $(filter-out $(libc-texi-generated) summary.texi $(examples), \ ++ $(texis)) \ ++ $(addprefix $(objpfx),$(filter $(libc-texi-generated) summary.texi \ ++ $(examples), $(texis))) ++ ++# Kludge: implicit rule so Make knows the one command does it all. ++chapters.% top-menu.%: libc-texinfo.sh $(texis-path) Makefile ++ AWK=$(AWK) $(SHELL) $< $(objpfx) \ ++ '$(chapters)' \ ++ '$(add-chapters)' \ ++ '$(appendices) $(licenses)' ++ ++ ++$(objpfx)libc.dvi $(objpfx)libc.pdf $(objpfx)libc.info: \ ++ $(addprefix $(objpfx),$(libc-texi-generated)) ++$(objpfx)libc.dvi $(objpfx)libc.pdf: texinfo.tex ++ ++html: $(objpfx)libc/index.html ++$(objpfx)libc/index.html: $(addprefix $(objpfx),$(libc-texi-generated)) ++ $(MAKEINFO) -P $(objpfx) -o $(objpfx)libc --html libc.texinfo ++ ++# Generate the summary from the Texinfo source files for each chapter. ++$(objpfx)summary.texi: $(objpfx)stamp-summary ; ++$(objpfx)stamp-summary: summary.awk $(filter-out $(objpfx)summary.texi, \ ++ $(texis-path)) ++ $(AWK) -f $^ | sort -t' ' -df -k 1,1 | tr '\014' '\012' \ ++ > $(objpfx)summary-tmp ++ $(move-if-change) $(objpfx)summary-tmp $(objpfx)summary.texi ++ touch $@ ++ ++# Generate a file which can be added to the `dir' content to provide direct ++# access to the documentation of the function, variables, and other ++# definitions. ++$(objpfx)dir-add.texi: xtract-typefun.awk $(texis-path) ++ (echo "@dircategory GNU C library functions and macros"; \ ++ echo "@direntry"; \ ++ $(AWK) -f $^ | sort; \ ++ echo "@end direntry") > $@.new ++ mv -f $@.new $@ ++ ++# The table with the math errors is generated. ++$(objpfx)libm-err.texi: $(objpfx)stamp-libm-err ++$(objpfx)stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\ ++ $(dir)/libm-test-ulps)) ++ pwd=`pwd`; \ ++ $(PERL) $< $$pwd/.. > $(objpfx)libm-err-tmp ++ $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi ++ touch $@ ++ ++# Generate a file with the version number. ++$(objpfx)version.texi: $(objpfx)stamp-version ; ++$(objpfx)stamp-version: $(common-objpfx)config.make ++ echo "@set VERSION $(version)" > $(objpfx)version-tmp ++ $(move-if-change) $(objpfx)version-tmp $(objpfx)version.texi ++ touch $@ ++ ++# Generate Texinfo files from the C source for the example programs. ++$(objpfx)%.c.texi: examples/%.c ++ sed -e '1,/^\*\/$$/d' \ ++ -e 's,[{}],@&,g' \ ++ -e 's,/\*\(@.*\)\*/,\1,g' \ ++ -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \ ++ -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\ ++ $< | expand > $@.new ++ mv -f $@.new $@ ++ ++$(objpfx)%.info: %.texinfo ++ LANGUAGE=C LC_ALL=C $(MAKEINFO) -P $(objpfx) --output=$@ $< ++ ++$(objpfx)%.dvi: %.texinfo ++ cd $(objpfx);$(TEXI2DVI) -I $(shell cd $(/dev/null 2>&1; then \ ++ test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\ ++ $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\ ++ else : ; fi ++endif ++# Catchall implicit rule for other installation targets from the parent. ++install-%: ; ++ ++$(inst_infodir)/libc.info: $(objpfx)libc.info ++ $(make-target-directory) ++ for file in $<*; do \ ++ $(INSTALL_DATA) $$file $(@D)/; \ ++ done ++ ++TAGS: $(minimal-dist) ++ $(ETAGS) -o $@ $^ +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -251,7 +251,7 @@ + # generated + endif # $(run-built-tests) + +-tests-special += $(objpfx)tst-errno-manual.out ++# tests-special += $(objpfx)tst-errno-manual.out + + include ../Rules + +--- a/sysdeps/mach/hurd/Makefile ++++ b/sysdeps/mach/hurd/Makefile +@@ -88,7 +88,7 @@ + -e 's, \.\./, $(..),g' > $@t + mv -f $@t $@ + +-$(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ; ++$(hurd)/bits/errno-disabled.h: $(common-objpfx)stamp-errnos ; + $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \ + $(mach-errnos-deps) $(common-objpfx)errnos.d + mkdir -p $(hurd-objpfx)bits diff --git a/autobuild/patches/glibc/series b/debian/patches/glibc/series similarity index 88% rename from autobuild/patches/glibc/series rename to debian/patches/glibc/series index e123587..362e7de 100644 --- a/autobuild/patches/glibc/series +++ b/debian/patches/glibc/series @@ -8,3 +8,5 @@ 0008-remove-clone3-for-compatibility-with-qq.patch 0009-prepend-trusted-dirs.patch 0010-Add-___brk_addr-symbol.patch +local-remove-manual.diff +local-ld-multiarch.diff diff --git a/autobuild/patches/patchelf/0001-add-remap-symvers.patch b/debian/patches/patchelf/0001-add-remap-symvers.patch similarity index 100% rename from autobuild/patches/patchelf/0001-add-remap-symvers.patch rename to debian/patches/patchelf/0001-add-remap-symvers.patch diff --git a/autobuild/patches/patchelf/series b/debian/patches/patchelf/series similarity index 100% rename from autobuild/patches/patchelf/series rename to debian/patches/patchelf/series diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..deaa8b0 --- /dev/null +++ b/debian/rules @@ -0,0 +1,252 @@ +#! /usr/bin/make -f + + +include /usr/share/dpkg/pkg-info.mk + +glibc-ver := 2.38 +patchelf-ver := 0.18.0 + +SUBSTVARS += -VglibcVer="$(glibc-ver)" + +glibc-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig-glibc.tar.xz +patchelf-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig-patchelf.tar.gz + +DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +lol_target_gnu_type := loongarch64-debian-linux-gnuow + +build_cflags := -pipe $(shell dpkg-buildflags --get CFLAGS_FOR_BUILD) $(shell dpkg-buildflags --get CPPFLAGS_FOR_BUILD) +build_cxxflags := -pipe $(shell dpkg-buildflags --get CXXFLAGS_FOR_BUILD) $(shell dpkg-buildflags --get CPPFLAGS_FOR_BUILD) +build_ldflags := $(shell dpkg-buildflags --get LDFLAGS_FOR_BUILD) +host_cflags := -pipe $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) +host_ldflags := $(shell dpkg-buildflags --get LDFLAGS) + +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +NJOBS := -j $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +endif + +BASE_CC = gcc +DEB_GCC_VERSION = -13 + +CC = $(DEB_HOST_GNU_TYPE)-$(BASE_CC)$(DEB_GCC_VERSION) +BUILD_CC = $(DEB_BUILD_GNU_TYPE)-$(BASE_CC) + +prefix=/usr +bindir=$(prefix)/bin +datadir=$(prefix)/share +complocaledir=$(prefix)/lib/locale +sysconfdir=/etc +libexecdir=$(prefix)/lib +rootsbindir=/sbin +includedir=$(prefix)/include +docdir=$(prefix)/share/doc +mandir=$(prefix)/share/man +sbindir=$(prefix)/sbin +vardbdir=/var/lib/misc +rtlddir=/lib64 +slibdir=/lib/$(DEB_HOST_MULTIARCH) +libdir=/usr/lib/$(DEB_HOST_MULTIARCH) + +get-orig-source: $(glibc-orig) $(patchelf-orig) + : + +$(glibc-orig): + curl -sSfL -o $@ https://ftp.debian.org/debian/pool/main/g/glibc/glibc_$(glibc-ver).orig.tar.xz +$(patchelf-orig): + curl -sSfL -o $@ https://ftp.debian.org/debian/pool/main/p/patchelf/patchelf_$(patchelf-ver).orig.tar.gz + +%: + dh $@ --without autoreconf + +override_dh_auto_configure: patch-src config-glibc config-patchelf +override_dh_auto_build: build-glibc build-patchelf +override_dh_auto_install: install-glibc symlink-hostlibs + +patchelf_build_dir := debian/build-dir/patchelf + +config-patchelf: patch-src.patchelf + dh_autoreconf -Dpatchelf + mkdir -p $(patchelf_build_dir) + cd $(patchelf_build_dir) && \ + $(CURDIR)/patchelf/configure \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_BUILD_GNU_TYPE) \ + CFLAGS='$(build_cflags)' \ + CXXFLAGS='$(build_cxxflags)' \ + LDFLAGS='$(build_ldflags)' + +glibc_build_dir := debian/build-dir/glibc +config-glibc: patch-src.glibc + mkdir -p $(glibc_build_dir) + rm -rf $(glibc_build_dir)/configparms + echo "BUILD_CC = $(BUILD_CC)" >> $(glibc_build_dir)/configparms + echo "CFLAGS = $(host_cflags)" >> $(glibc_build_dir)/configparms + echo "ASFLAGS = $(host_cflags)" >> $(glibc_build_dir)/configparms + echo "BUILD_CFLAGS = $(build_cflags)" >> $(glibc_build_dir)/configparms + echo "LDFLAGS = " >> $(glibc_build_dir)/configparms + echo "BASH := /bin/bash" >> $(glibc_build_dir)/configparms + echo "KSH := /bin/bash" >> $(glibc_build_dir)/configparms + echo "SHELL := /bin/bash" >> $(glibc_build_dir)/configparms + echo "LIBGD = no" >> $(glibc_build_dir)/configparms + echo "bindir = $(bindir)" >> $(glibc_build_dir)/configparms + echo "datadir = $(datadir)" >> $(glibc_build_dir)/configparms + echo "complocaledir = $(complocaledir)" >> $(glibc_build_dir)/configparms + echo "sysconfdir = $(sysconfdir)/liblol" >> $(glibc_build_dir)/configparms + echo "localtime-file = $(sysconfdir)/localtime" >> $(glibc_build_dir)/configparms + echo "libexecdir = $(libexecdir)" >> $(glibc_build_dir)/configparms + echo "rootsbindir = $(rootsbindir)" >> $(glibc_build_dir)/configparms + echo "includedir = $(includedir)" >> $(glibc_build_dir)/configparms + echo "docdir = $(docdir)" >> $(glibc_build_dir)/configparms + echo "mandir = $(mandir)" >> $(glibc_build_dir)/configparms + echo "sbindir = $(sbindir)" >> $(glibc_build_dir)/configparms + echo "vardbdir = $(vardbdir)" >> $(glibc_build_dir)/configparms + echo "libdir = $(libdir)" >> $(glibc_build_dir)/configparms + echo "slibdir = $(slibdir)" >> $(glibc_build_dir)/configparms + echo "rtlddir = $(rtlddir)" >> $(glibc_build_dir)/configparms + echo "user-defined-trusted-dirs-pre = /usr/local/lib/$(lol_target_gnu_type)/preload:/usr/lib/$(lol_target_gnu_type)/preload" >> $(glibc_build_dir)/configparms + echo "user-defined-trusted-dirs = /usr/local/lib/$(lol_target_gnu_type):/usr/lib/$(lol_target_gnu_type)" >> $(glibc_build_dir)/configparms + cd $(glibc_build_dir) && \ + CC=$(CC) \ + AUTOCONF=false \ + MAKEINFO=: \ + $(CURDIR)/glibc/configure \ + --host=$(lol_target_gnu_type) \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --prefix=/usr \ + --without-selinux \ + --enable-crypt \ + --enable-bind-now \ + --enable-fortify-source \ + --enable-stackguard-randomization \ + --enable-stack-protector=strong \ + --with-pkgversion="LibLoL $(DEB_VERSION)" \ + --with-bugurl="https://github.com/AOSC-Dev/liblol/issues" \ + --disable-nscd \ + --disable-werror \ + --enable-multi-arch \ + --enable-obsolete-rpc + +glibc_libs = libc.so.6 \ + nptl/libpthread.so.0 \ + elf/ld.so.1 \ + math/libm.so.6 \ + resolv/libresolv.so.2 \ + malloc/libc_malloc_debug.so.0 \ + nptl_db/libthread_db.so.1 \ + dlfcn/libdl.so.2 \ + locale/libBrokenLocale.so.1 \ + rt/librt.so.1 \ + crypt/libcrypt.so.1 \ + resolv/libanl.so.1 \ + login/libutil.so.1 \ + nis/libnsl.so.1 + +glibc_libs_targets = $(addprefix build-glibc-,$(subst /,-,$(glibc_libs))) +glibc_libs_targets_after = $(addprefix build-glibc-,$(filter-out libc.so.6,$(subst /,-,$(glibc_libs)))) + +glibc_libs_install_targets = $(addprefix install-glibc-,$(subst /,-,$(glibc_libs))) + +patchelf_bin := $(patchelf_build_dir)/src/patchelf + +$(patchelf_bin): build-patchelf + : + +build-glibc: $(glibc_libs_targets) + : + +$(glibc_libs_targets_after): build-glibc-libc.so.6 + +build-glibc-libc.so.6: + $(MAKE) -C $(glibc_build_dir) "$(CURDIR)/$(glibc_build_dir)/libc.so.6" $(NJOBS) + +glibc_cur_lib = $(subst -,/,$(*)) +glibc_cur_lib_dir = $(subst /,,$(dir $(glibc_cur_lib))) +glibc_cur_lib_name = $(notdir $(glibc_cur_lib)) +build-glibc-%: + $(MAKE) -C $(CURDIR)/glibc/$(glibc_cur_lib_dir) \ + "$(CURDIR)/$(glibc_build_dir)/$(glibc_cur_lib)" \ + subdir=$(glibc_cur_lib_dir) \ + ..=../ \ + objdir="$(CURDIR)/$(glibc_build_dir)" \ + $(NJOBS) + +TMPDIR ?= debian/tmp +install_libs_dir := $(TMPDIR)/usr/lib/$(lol_target_gnu_type) +install_preload_libs_dir := $(install_libs_dir)/preload +$(install_preload_libs_dir) $(install_libs_dir): + mkdir -p $@ +install-glibc-%: $(patchelf_bin) $(install_preload_libs_dir) + if [ "$(glibc_cur_lib)" = "nptl/libpthread.so.0" ] || [ "$(glibc_cur_lib)" = "libc.so.6" ]; then \ + $(patchelf_bin) \ + --page-size "$$(( 16 * 1024 ))" \ + --remap-symvers "GLIBC_2.27=GLIBC_2.0,GLIBC_2.2,GLIBC_2.2.1,GLIBC_2.2.2,GLIBC_2.2.3,GLIBC_2.2.4,GLIBC_2.2.6,GLIBC_2.3,GLIBC_2.3.2,GLIBC_2.3.3,GLIBC_2.3.4,GLIBC_2.4,GLIBC_2.5,GLIBC_2.6,GLIBC_2.7,GLIBC_2.8,GLIBC_2.9,GLIBC_2.10,GLIBC_2.11,GLIBC_2.12,GLIBC_2.13,GLIBC_2.14,GLIBC_2.15,GLIBC_2.16,GLIBC_2.17,GLIBC_2.18,GLIBC_2.19,GLIBC_2.20,GLIBC_2.21,GLIBC_2.22,GLIBC_2.23,GLIBC_2.24,GLIBC_2.25,GLIBC_2.26,GLIBC_2.27,GLIBC_2.28" \ + --also-remap-verneed \ + $(glibc_build_dir)/$(glibc_cur_lib) \ + --output $(install_preload_libs_dir)/$(glibc_cur_lib_name); \ + else \ + install -Dvm644 $(glibc_build_dir)/$(glibc_cur_lib) \ + -t $(install_preload_libs_dir)/; \ + fi + $(patchelf_bin) \ + --page-size "$$(( 16 * 1024 ))" \ + --remap-symvers "GLIBC_2.36=GLIBC_2.27,GLIBC_2.28" \ + --also-remap-verneed \ + $(install_preload_libs_dir)/$(glibc_cur_lib_name) + +install-glibc-dummy-ldso: + $(CC) -shared \ + $(host_cflags) \ + $(host_ldflags) \ + -x c /dev/null \ + -o $(install_preload_libs_dir)/ld-linux-loongarch-lp64d.so.1 \ + -Wl,--version-script -Wl,$(glibc_build_dir)/ld.map \ + -nostdlib + +install-glibc: $(glibc_libs_install_targets) $(install_preload_libs_dir) install-glibc-dummy-ldso + chmod 0644 $(install_preload_libs_dir)/* + chmod +x $(install_preload_libs_dir)/ld.so.1 + chmod +x $(install_preload_libs_dir)/libc.so.6 + mkdir -pv $(TMPDIR)/lib64 + ln -sfvr $(install_preload_libs_dir)/ld.so.1 $(TMPDIR)/lib64/ld.so.1 + +symlink-hostlibs: $(install_libs_dir) $(install_preload_libs_dir) + ln -sfv $(libdir)/libstdc++.so.6 $(install_preload_libs_dir)/ + +build-patchelf: + $(MAKE) -C $(patchelf_build_dir) all $(NJOBS) + +patch-src: patch-src.patchelf patch-src.glibc + +patch-src.%: + cd $* && QUILT_PATCHES=../debian/patches/$* quilt push -a + +override_dh_clean: clean-patch clean-patchelf + dh_clean + rm -rf debian/build-dir + +override_dh_shlibdeps: + dh_shlibdeps -l /usr/lib/$(lol_target_gnu_type)/preload + +override_dh_gencontrol: + dh_gencontrol -- $(SUBSTVARS) + +override_dh_fixperms: + dh_fixperms -Xld.so.1 -Xlibc.so.6 + +clean-patchelf: + dh_autoreconf_clean + +clean-patch: clean-patch.patchelf clean-patch.glibc + +clean-patch.%: + if [ -s $*/.pc/applied-patches ]; then \ + cd $* && QUILT_PATCHES=../debian/patches/$* quilt pop -q -a; \ + rm -rf .pc; \ + fi + +# dwz cannot handle our patched libs +override_dh_dwz: + : + +.PHONY: get-orig-source patch-src clean-patch config-glibc config-patchelf diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/genspec b/genspec deleted file mode 100644 index 8eefee3..0000000 --- a/genspec +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash - -# This script should be run in the rootfs of loongnix DaoXiangHu-stable - -set -e -o pipefail - -sed -i '/deb-src/s/#//' /etc/apt/sources.list -apt-get update -apt-get install --no-install-recommends -y \ - libgdk-pixbuf2.0-bin \ - libgtk2.0-0 \ - libgtk-3-0 \ - librsvg2-common \ - dconf-gsettings-backend \ - gvfs \ - glib-networking \ - gvfs-libs \ - fcitx-frontend-gtk2 \ - fcitx-frontend-gtk3 \ - ibus-gtk \ - ibus-gtk3 - -exec 3> spec.new - -echo "# AUTOGENERATED FILE from spec.main using genspec" >&3 - -cat spec.main >&3 - -fetch_pkg(){ - local pkg="$1" - local tag="$2" - - [ "$tag" ] - - info=$(apt-get --print-uris download "$pkg") - if [ "$?" -ne 0 ]; then - return 1 - fi - url=$(echo "$info" | sed "s/^[^']*'\([^']*\)'.*$/\1/" | sed 's/^.*\(pool.*\)$/\1/') - sum=$(echo "$info" | sed 's/^.*SHA256:\([^ ]*\) *.*$/\1/') - printf 'SRCS="$SRCS file::rename=%s%s.deb::${_mirror}/%s \\\n"\n' "$tag" "$pkg" "$url" - printf 'CHKSUMS="$CHKSUMS sha256::%s \\\n"\n' "$sum" -} - -fetch_src(){ - local pkg="$1" - - info=$(apt-get --print-uris -qq source "$pkg") - if [ "$?" -ne 0 ]; then - return 1 - fi - url=$(echo "$info" | sed "s/^[^']*'\([^']*\)'.*$/\1/" | sed 's/^.*\(pool.*\)$/\1/') - sum=$(echo "$info" | sed 's/^.*SHA256:\([^ ]*\) *.*$/\1/') - echo -n 'SRCS="$SRCS ' - echo "$url" | sed 's@^\(.*/\([^/]*\)\)$@file::rename=\2::${_mirror}/\1@; s@$@ \\@' - echo '"' - echo -n 'CHKSUMS="$CHKSUMS ' - echo "$sum" | sed 's@^@sha256::@; s@$@ \\@' - echo '"' -} -while read pkg; do - if [ -z "$pkg" ]; then - continue - fi - nodbg=0 - dev=0 - src=0 - while :; do - case $pkg in - *:nodbg) - nodbg=1 - pkg=${pkg%:nodbg} - ;; - *:src) - src=1 - pkg=${pkg%:src} - ;; - *:dev) - dev=1 - pkg=${pkg%:dev} - ;; - *) - break - ;; - esac - done - case $pkg in - *-dev) - devpkg=1 - ;; - *) - devpkg=0 - ;; - esac - if [ "$src" = "0" ]; then - tag="" - if [ "$devpkg" = 0 ]; then - tag="${tag}dist_" - fi - if [ "$dev" = 1 ]; then - tag="${tag}dev_" - fi - fetch_pkg "$pkg" "$tag">&3 - if [ "$nodbg" = "0" ] && [ "$devpkg" = "0" ] ; then - fetch_pkg "$pkg-dbgsym" "dist_" >&3 || fetch_pkg "$pkg-dbg" "dist_" >&3 - fi - else - fetch_src "$pkg" >&3 - fi -done < manifest - -exec 3>&- -mv spec.new spec diff --git a/manifest b/manifest deleted file mode 100644 index e69de29..0000000 diff --git a/spec b/spec deleted file mode 100644 index 81f5332..0000000 --- a/spec +++ /dev/null @@ -1,13 +0,0 @@ -# AUTOGENERATED FILE from spec.main using genspec -VER=0.1.4 -_mirror="http://pkg.loongnix.cn/loongnix" -__GLIBC_VER=2.38 - -SRCS="\ - file::rename=glibc.tar.xz::https://ftp.gnu.org/gnu/glibc/glibc-${__GLIBC_VER}.tar.xz \ - file::rename=patchelf.tar.gz::https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz \ -" -CHKSUMS="\ - sha256::fb82998998b2b29965467bc1b69d152e9c307d2cf301c9eafb4555b770ef3fd2 \ - sha256::64de10e4c6b8b8379db7e87f58030f336ea747c0515f381132e810dbf84a86e7 \ -" diff --git a/spec.main b/spec.main deleted file mode 100644 index d3be72d..0000000 --- a/spec.main +++ /dev/null @@ -1,12 +0,0 @@ -VER=0.1.4 -_mirror="http://pkg.loongnix.cn/loongnix" -__GLIBC_VER=2.38 - -SRCS="\ - file::rename=glibc.tar.xz::https://ftp.gnu.org/gnu/glibc/glibc-${__GLIBC_VER}.tar.xz \ - file::rename=patchelf.tar.gz::https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz \ -" -CHKSUMS="\ - sha256::fb82998998b2b29965467bc1b69d152e9c307d2cf301c9eafb4555b770ef3fd2 \ - sha256::64de10e4c6b8b8379db7e87f58030f336ea747c0515f381132e810dbf84a86e7 \ -"