Package: golang-1.21 Version: 1.21.3 Severity: wishlist Tags: patch User: debian-loonga...@lists.debian.org Usertags: loong64
Hi, Golang upstream supports loong64 starting from Go1.19 version, and currently all dependencies for building golang-1.21 package on debian sid have been met. Golang-1.21 on loong64 can now be built. The three backport patches in the attachment are mainly to solve glibc dynamic linker path errors([1]) and relocation-related errors([2] [3]), otherwise related tests may fail. [1] https://go-review.googlesource.com/c/go/+/526535 [2] https://go-review.googlesource.com/c/go/+/528455 [3] https://go-review.googlesource.com/c/go/+/537615 -- thanks, Guoqi Chen
>From 5af694637ec9d26dcf94c06a542724b3e15f9ff7 Mon Sep 17 00:00:00 2001 From: Guoqi Chen <chengu...@loongson.cn> Date: Fri, 27 Oct 2023 09:47:52 +0000 Subject: [PATCH] Add support for loong64 --- debian/control | 2 +- debian/control.in | 2 +- debian/helpers/goenv.sh | 2 +- ...l-loong64-correct-the-glibc-dynamic-.patch | 36 +++++ ...l-loadelf-correct-the-relocation-siz.patch | 38 +++++ ...nk-add-additional-relocations-for-lo.patch | 132 ++++++++++++++++++ debian/patches/series | 4 + 7 files changed, 213 insertions(+), 3 deletions(-) create mode 100644 debian/patches/0001-cmd-link-internal-loong64-correct-the-glibc-dynamic-.patch create mode 100644 debian/patches/0002-cmd-link-internal-loadelf-correct-the-relocation-siz.patch create mode 100644 debian/patches/0003-debug-elf-cmd-link-add-additional-relocations-for-lo.patch create mode 100644 debian/patches/series diff --git a/debian/control b/debian/control index 0fb79d3..426c59d 100644 --- a/debian/control +++ b/debian/control @@ -22,7 +22,7 @@ Homepage: https://go.dev/ Rules-Requires-Root: no Package: golang-1.21-go -Architecture: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el riscv64 s390x +Architecture: amd64 arm64 armel armhf i386 loong64 mips mips64el mipsel ppc64 ppc64el riscv64 s390x Depends: golang-1.21-src (>= ${source:Version}), ${misc:Depends}, ${perl:Depends}, diff --git a/debian/control.in b/debian/control.in index c65794e..2ef1965 100644 --- a/debian/control.in +++ b/debian/control.in @@ -18,7 +18,7 @@ Homepage: https://go.dev/ Rules-Requires-Root: no Package: golang-X.Y-go -Architecture: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el riscv64 s390x +Architecture: amd64 arm64 armel armhf i386 loong64 mips mips64el mipsel ppc64 ppc64el riscv64 s390x Depends: golang-X.Y-src (>= ${source:Version}), ${misc:Depends}, ${perl:Depends}, diff --git a/debian/helpers/goenv.sh b/debian/helpers/goenv.sh index 172df51..488537a 100755 --- a/debian/helpers/goenv.sh +++ b/debian/helpers/goenv.sh @@ -11,7 +11,7 @@ __goos__deb_arch_os() { __goarch__deb_arch_cpu() { case "$1" in - amd64|arm|arm64|mips|ppc64|riscv64|s390x) echo "$1" ;; + amd64|arm|arm64|loong64|mips|ppc64|riscv64|s390x) echo "$1" ;; i386) echo 386 ;; mips64el) echo mips64le ;; mipsel) echo mipsle ;; diff --git a/debian/patches/0001-cmd-link-internal-loong64-correct-the-glibc-dynamic-.patch b/debian/patches/0001-cmd-link-internal-loong64-correct-the-glibc-dynamic-.patch new file mode 100644 index 0000000..3e42a7b --- /dev/null +++ b/debian/patches/0001-cmd-link-internal-loong64-correct-the-glibc-dynamic-.patch @@ -0,0 +1,36 @@ +From 050c02f1f0395c08583588a60d166a0f7562f322 Mon Sep 17 00:00:00 2001 +From: limeidan <limei...@loongson.cn> +Date: Wed, 6 Sep 2023 17:09:35 +0800 +Subject: [PATCH 1/3] cmd/link/internal/loong64: correct the glibc dynamic + linker path. + +Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_program_interpreter_path + +Change-Id: Ic2598110cc091362cb09f877b6b86433cacf32c6 +Reviewed-on: https://go-review.googlesource.com/c/go/+/526535 +Reviewed-by: Ian Lance Taylor <i...@google.com> +Run-TryBot: Ian Lance Taylor <i...@google.com> +Auto-Submit: Ian Lance Taylor <i...@google.com> +TryBot-Result: Gopher Robot <go...@golang.org> +Reviewed-by: abner chenc <chengu...@loongson.cn> +Reviewed-by: Cherry Mui <cherr...@google.com> +--- + src/cmd/link/internal/loong64/obj.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/cmd/link/internal/loong64/obj.go b/src/cmd/link/internal/loong64/obj.go +index c3f6ed9386..fd193a2445 100644 +--- a/src/cmd/link/internal/loong64/obj.go ++++ b/src/cmd/link/internal/loong64/obj.go +@@ -29,7 +29,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + + ELF: ld.ELFArch{ +- Linuxdynld: "/lib64/ld.so.1", ++ Linuxdynld: "/lib64/ld-linux-loongarch-lp64d.so.1", + LinuxdynldMusl: "/lib64/ld-musl-loongarch.so.1", + Freebsddynld: "XXX", + Openbsddynld: "XXX", +-- +2.38.1 + diff --git a/debian/patches/0002-cmd-link-internal-loadelf-correct-the-relocation-siz.patch b/debian/patches/0002-cmd-link-internal-loadelf-correct-the-relocation-siz.patch new file mode 100644 index 0000000..40a2586 --- /dev/null +++ b/debian/patches/0002-cmd-link-internal-loadelf-correct-the-relocation-siz.patch @@ -0,0 +1,38 @@ +From 038503336f7560768aae5a740eff142b007b7234 Mon Sep 17 00:00:00 2001 +From: limeidan <limei...@loongson.cn> +Date: Thu, 14 Sep 2023 20:11:07 +0800 +Subject: [PATCH 2/3] cmd/link/internal/loadelf: correct the relocation size of + R_LARCH_64 + +Change-Id: If3eaca8b92e8f5265c7763d13021a6353b9df9b6 +Reviewed-on: https://go-review.googlesource.com/c/go/+/528455 +Reviewed-by: Cherry Mui <cherr...@google.com> +Reviewed-by: Than McIntosh <th...@google.com> +Reviewed-by: abner chenc <chengu...@loongson.cn> +LUCI-TryBot-Result: Go LUCI <golang-sco...@luci-project-accounts.iam.gserviceaccount.com> +--- + src/cmd/link/internal/loadelf/ldelf.go | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go +index 942d54c06c..5ab7cf2204 100644 +--- a/src/cmd/link/internal/loadelf/ldelf.go ++++ b/src/cmd/link/internal/loadelf/ldelf.go +@@ -1012,11 +1012,13 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, uint8, error) { + LOONG64 | uint32(elf.R_LARCH_SOP_PUSH_ABSOLUTE)<<16, + LOONG64 | uint32(elf.R_LARCH_MARK_LA)<<16, + LOONG64 | uint32(elf.R_LARCH_SOP_POP_32_S_0_10_10_16_S2)<<16, +- LOONG64 | uint32(elf.R_LARCH_64)<<16, + LOONG64 | uint32(elf.R_LARCH_MARK_PCREL)<<16, + LOONG64 | uint32(elf.R_LARCH_32_PCREL)<<16: + return 4, 4, nil + ++ case LOONG64 | uint32(elf.R_LARCH_64)<<16: ++ return 8, 8, nil ++ + case S390X | uint32(elf.R_390_8)<<16: + return 1, 1, nil + +-- +2.38.1 + diff --git a/debian/patches/0003-debug-elf-cmd-link-add-additional-relocations-for-lo.patch b/debian/patches/0003-debug-elf-cmd-link-add-additional-relocations-for-lo.patch new file mode 100644 index 0000000..99c11bb --- /dev/null +++ b/debian/patches/0003-debug-elf-cmd-link-add-additional-relocations-for-lo.patch @@ -0,0 +1,132 @@ +From e1c1bd1719e04b99990f3276cdef28ca36fa8bb1 Mon Sep 17 00:00:00 2001 +From: Guoqi Chen <chengu...@loongson.cn> +Date: Tue, 24 Oct 2023 16:24:39 +0800 +Subject: [PATCH 3/3] debug/elf,cmd/link: add additional relocations for + loong64 + +The Linker Relaxation feature on Loong64 is already supported in binutils 2.41. +The intermediate code generated after enabling this feature introduces three +reloc types R_LARCH_B26, R_LARCH_ADD32 and R_LARCH_SUB32. + +The other relocation types are not currently used when running all.bash, but +in order to avoid the host tool chain making the decision to use it we don't +have to catch it every time. + +The LoongArch ABI at here: +https://github.com/loongson/la-abi-specs/blob/release/la-abi.adoc + +Corresponding binutils implementation: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=be1ebb6710a8f707bd4b0eecbd00f4f4964050e5 +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=1b6fccd28db14fffe75ff6755307047ef932c81e + +Fixes #63725 + +Change-Id: I891115cfdbcf785ab494c881d5f9d1bf8748da8b +--- + api/next/63725.txt | 18 ++++++++++++++++++ + src/cmd/link/internal/loadelf/ldelf.go | 18 +++++++++++++++++- + src/debug/elf/elf.go | 18 ++++++++++++++++++ + 3 files changed, 53 insertions(+), 1 deletion(-) + create mode 100644 api/next/63725.txt + +diff --git a/api/next/63725.txt b/api/next/63725.txt +new file mode 100644 +index 0000000000..ff3e05348b +--- /dev/null ++++ b/api/next/63725.txt +@@ -0,0 +1,18 @@ ++pkg debug/elf, const R_LARCH_64_PCREL = 109 #63725 ++pkg debug/elf, const R_LARCH_64_PCREL R_LARCH #63725 ++pkg debug/elf, const R_LARCH_ADD6 = 105 #63725 ++pkg debug/elf, const R_LARCH_ADD6 R_LARCH #63725 ++pkg debug/elf, const R_LARCH_ADD_ULEB128 = 107 #63725 ++pkg debug/elf, const R_LARCH_ADD_ULEB128 R_LARCH #63725 ++pkg debug/elf, const R_LARCH_ALIGN = 102 #63725 ++pkg debug/elf, const R_LARCH_ALIGN R_LARCH #63725 ++pkg debug/elf, const R_LARCH_CFA = 104 #63725 ++pkg debug/elf, const R_LARCH_CFA R_LARCH #63725 ++pkg debug/elf, const R_LARCH_DELETE = 101 #63725 ++pkg debug/elf, const R_LARCH_DELETE R_LARCH #63725 ++pkg debug/elf, const R_LARCH_PCREL20_S2 = 103 #63725 ++pkg debug/elf, const R_LARCH_PCREL20_S2 R_LARCH #63725 ++pkg debug/elf, const R_LARCH_SUB6 = 106 #63725 ++pkg debug/elf, const R_LARCH_SUB6 R_LARCH #63725 ++pkg debug/elf, const R_LARCH_SUB_ULEB128 = 108 #63725 ++pkg debug/elf, const R_LARCH_SUB_ULEB128 R_LARCH #63725 +diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go +index 5ab7cf2204..407c5d974a 100644 +--- a/src/cmd/link/internal/loadelf/ldelf.go ++++ b/src/cmd/link/internal/loadelf/ldelf.go +@@ -1007,16 +1007,32 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, uint8, error) { + MIPS64 | uint32(elf.R_MIPS_GOT_DISP)<<16: + return 4, 4, nil + ++ case LOONG64 | uint32(elf.R_LARCH_ADD8)<<16, ++ LOONG64 | uint32(elf.R_LARCH_SUB8)<<16: ++ return 1, 1, nil ++ ++ case LOONG64 | uint32(elf.R_LARCH_ADD16)<<16, ++ LOONG64 | uint32(elf.R_LARCH_SUB16)<<16: ++ return 2, 2, nil ++ + case LOONG64 | uint32(elf.R_LARCH_SOP_PUSH_PCREL)<<16, + LOONG64 | uint32(elf.R_LARCH_SOP_PUSH_GPREL)<<16, + LOONG64 | uint32(elf.R_LARCH_SOP_PUSH_ABSOLUTE)<<16, + LOONG64 | uint32(elf.R_LARCH_MARK_LA)<<16, + LOONG64 | uint32(elf.R_LARCH_SOP_POP_32_S_0_10_10_16_S2)<<16, + LOONG64 | uint32(elf.R_LARCH_MARK_PCREL)<<16, ++ LOONG64 | uint32(elf.R_LARCH_ADD24)<<16, ++ LOONG64 | uint32(elf.R_LARCH_ADD32)<<16, ++ LOONG64 | uint32(elf.R_LARCH_SUB24)<<16, ++ LOONG64 | uint32(elf.R_LARCH_SUB32)<<16, ++ LOONG64 | uint32(elf.R_LARCH_B26)<<16, + LOONG64 | uint32(elf.R_LARCH_32_PCREL)<<16: + return 4, 4, nil + +- case LOONG64 | uint32(elf.R_LARCH_64)<<16: ++ case LOONG64 | uint32(elf.R_LARCH_64)<<16, ++ LOONG64 | uint32(elf.R_LARCH_ADD64)<<16, ++ LOONG64 | uint32(elf.R_LARCH_SUB64)<<16, ++ LOONG64 | uint32(elf.R_LARCH_64_PCREL)<<16: + return 8, 8, nil + + case S390X | uint32(elf.R_390_8)<<16: +diff --git a/src/debug/elf/elf.go b/src/debug/elf/elf.go +index c982c684ba..63acddc166 100644 +--- a/src/debug/elf/elf.go ++++ b/src/debug/elf/elf.go +@@ -2365,6 +2365,15 @@ const ( + R_LARCH_TLS_GD_HI20 R_LARCH = 98 + R_LARCH_32_PCREL R_LARCH = 99 + R_LARCH_RELAX R_LARCH = 100 ++ R_LARCH_DELETE R_LARCH = 101 ++ R_LARCH_ALIGN R_LARCH = 102 ++ R_LARCH_PCREL20_S2 R_LARCH = 103 ++ R_LARCH_CFA R_LARCH = 104 ++ R_LARCH_ADD6 R_LARCH = 105 ++ R_LARCH_SUB6 R_LARCH = 106 ++ R_LARCH_ADD_ULEB128 R_LARCH = 107 ++ R_LARCH_SUB_ULEB128 R_LARCH = 108 ++ R_LARCH_64_PCREL R_LARCH = 109 + ) + + var rlarchStrings = []intName{ +@@ -2457,6 +2466,15 @@ var rlarchStrings = []intName{ + {98, "R_LARCH_TLS_GD_HI20"}, + {99, "R_LARCH_32_PCREL"}, + {100, "R_LARCH_RELAX"}, ++ {101, "R_LARCH_DELETE"}, ++ {102, "R_LARCH_ALIGN"}, ++ {103, "R_LARCH_PCREL20_S2"}, ++ {104, "R_LARCH_CFA"}, ++ {105, "R_LARCH_ADD6"}, ++ {106, "R_LARCH_SUB6"}, ++ {107, "R_LARCH_ADD_ULEB128"}, ++ {108, "R_LARCH_SUB_ULEB128"}, ++ {109, "R_LARCH_64_PCREL"}, + } + + func (i R_LARCH) String() string { return stringName(uint32(i), rlarchStrings, false) } +-- +2.38.1 + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..34f38c9 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,4 @@ +#loong64 +0001-cmd-link-internal-loong64-correct-the-glibc-dynamic-.patch +0002-cmd-link-internal-loadelf-correct-the-relocation-siz.patch +0003-debug-elf-cmd-link-add-additional-relocations-for-lo.patch -- 2.42.0
<<attachment: chenguoqi.vcf>>