Ben Hutchings
2020-Jul-25 23:09 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
On Sat, 2020-07-25 at 15:16 -0700, Bill Wendling wrote:> On Sat, Jul 25, 2020 at 2:56 PM Ben Hutchings <ben at decadent.org.uk> wrote: > > On Sat, 2020-07-25 at 14:36 -0700, Bill Wendling wrote: > > [...] > > > I upstreamed a few patches to klibc to fix a few linker errors. Some > > > of these might help: > > > > I applied v3 of your patch series and never saw this later version. > > > > > - cfc4e4c9591c73edc786aebbe83b371fec36fec8 - Conditionalized > > > non-supported flags. > > > - 1b014f8401fc5b3dc803e2cae06ac5c803dc89cb - Add "-fno-common" > > > - 1e876662002eac9662357c7feaee12be04107d32 - Use proper libc > > > - f07a8f75b8ebfea71254cd8829c0476b6b6683e1 - Adjust some flags for ld.lld > > > - 7f0aa03493dc9ab8c1d2798f6586bfbc5f1de702 - Use "-ffreestanding" > > > (fixes using unlocked versions of calls) > > > > > > There are also a bunch of clang warnings Michael Davidson fixed in the > > > klibc tree. > > > > *Which* klibc tree? > > > > Ben. > > > The one here I think: https://git.kernel.org/pub/scm/libs/klibc/klibc.gitThat's where I'm pushing. It has v3 of your patch series, and no other recent changes related to Clang or lld. So please send over any other fixes you have. Ben. -- Ben Hutchings Theory and practice are closer in theory than in practice - John Levine -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20200726/6c307a41/attachment-0001.sig>
Bill Wendling
2020-Jul-26 06:13 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
On Sat, Jul 25, 2020 at 4:10 PM Ben Hutchings <ben at decadent.org.uk> wrote:> On Sat, 2020-07-25 at 15:16 -0700, Bill Wendling wrote: > > On Sat, Jul 25, 2020 at 2:56 PM Ben Hutchings <ben at decadent.org.uk> wrote: > > > On Sat, 2020-07-25 at 14:36 -0700, Bill Wendling wrote: > > > [...] > > > > I upstreamed a few patches to klibc to fix a few linker errors. Some > > > > of these might help: > > > > > > I applied v3 of your patch series and never saw this later version. > > > > > > > - cfc4e4c9591c73edc786aebbe83b371fec36fec8 - Conditionalized > > > > non-supported flags. > > > > - 1b014f8401fc5b3dc803e2cae06ac5c803dc89cb - Add "-fno-common" > > > > - 1e876662002eac9662357c7feaee12be04107d32 - Use proper libc > > > > - f07a8f75b8ebfea71254cd8829c0476b6b6683e1 - Adjust some flags for ld.lld > > > > - 7f0aa03493dc9ab8c1d2798f6586bfbc5f1de702 - Use "-ffreestanding" > > > > (fixes using unlocked versions of calls) > > > > > > > > There are also a bunch of clang warnings Michael Davidson fixed in the > > > > klibc tree. > > > > > > *Which* klibc tree? > > > > > > Ben. > > > > > The one here I think: https://git.kernel.org/pub/scm/libs/klibc/klibc.git > > That's where I'm pushing. It has v3 of your patch series, and no other > recent changes related to Clang or lld. > > So please send over any other fixes you have. >Hi Ben, I'm sorry. I don't know what you want. The patches I see in top-of-tree klibc look to be the ones I listed above. Though I don't see the -ffreestanding and the -Ttext-segment changes commit 3dbbaade8f836f18e1f739a61cc359d799d1127f Author: Bill Wendling <morbo at google.com> Date: Mon Jun 4 16:55:01 2018 -0700 klibc: add -ffreestanding to required flags Newer clang versions need the '-ffreestanding' flag because new changes convert system calls to their unlocked versions, which don't exist in the kernel library. Signed-off-by: Bill Wendling <morbo at google.com> diff --git a/gbuild/klibc/scripts/Kbuild.klibc b/gbuild/klibc/scripts/Kbuild.klibc index 4e9f5eb4846e..18f7291a1f61 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -67,7 +67,8 @@ include $(srctree)/scripts/Kbuild.include # --------------------------------------------------------------------------- KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ - $(call cc-option, -fwrapv, ) + $(call cc-option, -fwrapv, ) \ + $(call cc-option, -ffreestanding, ) KLIBCARCHREQFLAGS : KLIBCOPTFLAGS : KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter \ commit c3961aac9362f362c5aae8ea50d67c0a9766c1c7 Author: Stanislav Fomichev <sdf at google.com> Date: Thu Feb 27 09:51:29 2020 -0800 klibc: support llvm's lld Clang that we have in google3 started emitting relocations that our outdated binutils ld doesn't support. In an effort to switch userspace to use llvm's ld, let's teach klibc some ld.lld quirks. Signed-off-by: Stanislav Fomichev <sdf at google.com> Signed-off-by: Bill Wendling <morbo at google.com> diff --git a/Makefile b/Makefile index a60161ccca5b..46d35fe77c3b 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,9 @@ export NM := $(KLIBCROSS)nm export OBJCOPY := $(KLIBCROSS)objcopy export OBJDUMP := $(KLIBCROSS)objdump +LLD := $(shell $(LD) --version 2>&1 | grep LLD) +export IMAGE_BASE=$(if $(LLD),--image-base,-Ttext-segment) + NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include) ARCH := $(shell uname -m | sed -e s/i.86/i386/ \ diff --git a/usr/klibc/arch/i386/MCONFIG b/usr/klibc/arch/i386/MCONFIG index 0704669500f0..baa7e59854f8 100644 --- a/usr/klibc/arch/i386/MCONFIG +++ b/usr/klibc/arch/i386/MCONFIG @@ -30,4 +30,4 @@ KLIBCBITSIZE = 32 # This address needs to be reachable using normal inter-module # calls, and work on the memory models for this architecture # 96 MB - normal binaries start at 128 MB -KLIBCSHAREDFLAGS = -Ttext-segment 0x06000000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x06000000 diff --git a/usr/klibc/arch/mips64/MCONFIG b/usr/klibc/arch/mips64/MCONFIG index 6a4b41b2f85c..3d7f20da08be 100644 --- a/usr/klibc/arch/mips64/MCONFIG +++ b/usr/klibc/arch/mips64/MCONFIG @@ -20,4 +20,4 @@ KLIBCBITSIZE = 64 # load address, use the very top of the 256M region (minus 2MB) # # Use -Ttext-segment so that the special .MIPS* sections are moved as well. -KLIBCSHAREDFLAGS = -Ttext-segment 0x12FE00000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x12FE00000 diff --git a/usr/klibc/arch/ppc/MCONFIG b/usr/klibc/arch/ppc/MCONFIG index 8220f6b93fa4..ec859e8941d9 100644 --- a/usr/klibc/arch/ppc/MCONFIG +++ b/usr/klibc/arch/ppc/MCONFIG @@ -20,7 +20,7 @@ KLIBCBITSIZE = 32 # calls, and work on the memory models for this architecture # 256-16 MB - normal binaries start at 256 MB, and jumps are limited # to +/- 16 MB -KLIBCSHAREDFLAGS = -Ttext-segment 0x0f800000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x0f800000 # The asm include files live in asm-powerpc KLIBCASMARCH = powerpc diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG index d6e3a85c4b5f..6b553f9787bb 100644 --- a/usr/klibc/arch/ppc64/MCONFIG +++ b/usr/klibc/arch/ppc64/MCONFIG @@ -26,7 +26,7 @@ endif # calls, and work on the memory models for this architecture # 256-16 MB - normal binaries start at 256 MB, and jumps are limited # to +/- 16 MB -KLIBCSHAREDFLAGS = -Ttext-segment 0x0f000000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x0f000000 # The asm include files live in asm-powerpc KLIBCASMARCH = powerpc diff --git a/usr/klibc/arch/riscv64/MCONFIG b/usr/klibc/arch/riscv64/MCONFIG index 61681509d89d..2ea257548417 100644 --- a/usr/klibc/arch/riscv64/MCONFIG +++ b/usr/klibc/arch/riscv64/MCONFIG @@ -17,4 +17,4 @@ endif KLIBCBITSIZE = 64 # Normal binaries start at 64 KB, so start the libary at 2 MB. -KLIBCSHAREDFLAGS =-Ttext-segment 0x00200000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x00200000 diff --git a/usr/klibc/arch/sparc64/MCONFIG b/usr/klibc/arch/sparc64/MCONFIG index c83398559f84..767232fce80e 100644 --- a/usr/klibc/arch/sparc64/MCONFIG +++ b/usr/klibc/arch/sparc64/MCONFIG @@ -18,4 +18,4 @@ KLIBCLDFLAGS = -m elf64_sparc # calls, and work on the memory models for this architecture # Normal binaries start at 1 MB; the linker wants 1 MB alignment, # and call instructions have a 30-bit signed offset, << 2. -KLIBCSHAREDFLAGS = -Ttext-segment 0x80000000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x80000000 diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG index a68d5692e04c..08a05f51863b 100644 --- a/usr/klibc/arch/x86_64/MCONFIG +++ b/usr/klibc/arch/x86_64/MCONFIG @@ -41,4 +41,4 @@ KLIBCLDFLAGS = -m elf_x86_64 # The old default was max-page-size=0x100000, but that also results # in a broken layout with binutils 2.30. Since there's no # architectural page size betwen 4 KB and 2MB, set it to 4 KB. -KLIBCSHAREDFLAGS = -Ttext-segment 0x00200000 -z max-page-size=0x1000 +KLIBCSHAREDFLAGS = $(IMAGE_BASE) 0x00200000 -z max-page-size=0x1000 bw
Ben Hutchings
2020-Jul-26 20:52 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
On Sat, 2020-07-25 at 23:13 -0700, Bill Wendling wrote:> On Sat, Jul 25, 2020 at 4:10 PM Ben Hutchings <ben at decadent.org.uk> wrote: > > On Sat, 2020-07-25 at 15:16 -0700, Bill Wendling wrote: > > > On Sat, Jul 25, 2020 at 2:56 PM Ben Hutchings <ben at decadent.org.uk> wrote: > > > > On Sat, 2020-07-25 at 14:36 -0700, Bill Wendling wrote: > > > > [...] > > > > > I upstreamed a few patches to klibc to fix a few linker errors. Some > > > > > of these might help: > > > > > > > > I applied v3 of your patch series and never saw this later version. > > > > > > > > > - cfc4e4c9591c73edc786aebbe83b371fec36fec8 - Conditionalized > > > > > non-supported flags. > > > > > - 1b014f8401fc5b3dc803e2cae06ac5c803dc89cb - Add "-fno-common" > > > > > - 1e876662002eac9662357c7feaee12be04107d32 - Use proper libc > > > > > - f07a8f75b8ebfea71254cd8829c0476b6b6683e1 - Adjust some flags for ld.lld > > > > > - 7f0aa03493dc9ab8c1d2798f6586bfbc5f1de702 - Use "-ffreestanding" > > > > > (fixes using unlocked versions of calls) > > > > > > > > > > There are also a bunch of clang warnings Michael Davidson fixed in the > > > > > klibc tree. > > > > > > > > *Which* klibc tree? > > > > > > > > Ben. > > > > > > > The one here I think: https://git.kernel.org/pub/scm/libs/klibc/klibc.git > > > > That's where I'm pushing. It has v3 of your patch series, and no other > > recent changes related to Clang or lld. > > > > So please send over any other fixes you have. > > > Hi Ben, > > I'm sorry. I don't know what you want. The patches I see in > top-of-tree klibc look to be the ones I listed above. Though I don't > see the -ffreestanding and the -Ttext-segment changes[...] OK. The -ffreestanding change should not be necessary after this: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=8c056cab6c8cce0b5dbc2c3141060f89a6ffc905 The change to replace -Ttext-segment is there as: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=eaca2447991709cddfd8c42f3fa4a2e890d2cce8 However, ld.lld 9.0.1 fails to link programs using the klibc shared library. Ben. -- Ben Hutchings Theory and practice are closer in theory than in practice - John Levine -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20200726/994bba3f/attachment.sig>