Bill Wendling
2020-Mar-29 11:38 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
- Renamed IMAGE_BASE to LD_IMAGE_BASE_OPT. - Moved "-fcommon" to KLIBCREQFLAGS in scripts/Kbuild.klibc. - Remove "dash" warning fixes which have been upstreamed. - Conditionalize the inclusion of compiler flags by using the proper compiler name or "cc-option". - Added "-Werror" to "cc-option" to catch flags that cause warnings. - Retain "-nostdinc -iwithprefix include" and use the proper clang flag to get the path to find "stdarg.h". - Move "-fno-builtin-bcmp" to KLIBCREQFLAGS in scripts/Kbuild.klibc. Bill Wendling (4): [klibc] Kbuild: add support for clang builds [klibc] Kbuild: support clang's lld [klibc] Kbuild: Add "-fcommon" for clang builds [klibc] Clean up clang warnings Makefile | 3 +++ scripts/Kbuild.include | 8 ++++++-- scripts/Kbuild.klibc | 14 ++++++++++---- usr/kinit/initrd.c | 2 +- usr/kinit/ramdisk_load.c | 2 +- usr/klibc/Kbuild | 4 ++-- usr/klibc/arch/i386/MCONFIG | 2 +- usr/klibc/arch/mips64/MCONFIG | 5 +++-- usr/klibc/arch/ppc/MCONFIG | 2 +- usr/klibc/arch/ppc64/MCONFIG | 2 +- usr/klibc/arch/riscv64/MCONFIG | 2 +- usr/klibc/arch/sparc64/MCONFIG | 2 +- usr/klibc/arch/x86_64/MCONFIG | 8 +++++--- 13 files changed, 36 insertions(+), 20 deletions(-) -- 2.26.0.rc2.310.g2932bb562d-goog
Bill Wendling
2020-Mar-29 11:38 UTC
[klibc] [kvm-unit-tests PATCH v3 1/4] Kbuild: add support for clang builds
Add cc-name to klibc/scripts/Kbuild.include. Make optimization flags not supported by clang conditional on cc-name. Use "--print-file-name=include" and "--print-libgcc-file-name" when using clang. Use cc-option to enable compiler-specific flags. Mark "bcmp" as not a builtin to prevent clang from using it. Signed-off-by: Bill Wendling <morbo at google.com> --- scripts/Kbuild.include | 8 ++++++-- scripts/Kbuild.klibc | 13 +++++++++---- usr/klibc/Kbuild | 4 ++-- usr/klibc/arch/x86_64/MCONFIG | 6 ++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index a048ec7a..5604b3e3 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -110,12 +110,12 @@ as-instr = $(call try-run,\ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -Werror -c -xc /dev/null -o "$$TMP",$(1),$(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -Werror -c -xc /dev/null -o "$$TMP",y,n) # cc-option-align # Prefix align with either -falign or -malign @@ -127,6 +127,10 @@ cc-option-align = $(subst -functions=0,,\ cc-disable-warning = $(call try-run,\ $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1))) +# cc-name +# Expands to either gcc or clang +cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) + # cc-version # Usage gcc-ver := $(call cc-version) cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index afc9a546..ca2539d6 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -69,6 +69,7 @@ include $(srctree)/scripts/Kbuild.include KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ $(call cc-option, -fwrapv, ) \ $(call cc-option, -fno-PIE, ) \ + $(call cc-option, -fno-builtin-bcmp, ) \ -ggdb KLIBCARCHREQFLAGS : KLIBCOPTFLAGS :@@ -108,10 +109,14 @@ KLIBCOBJDUMP := $(OBJDUMP) # klibc include paths KLIBCCPPFLAGS := -nostdinc -iwithprefix include \ - -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \ + -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \ -I$(KLIBCINC)/bits$(KLIBCBITSIZE) \ - -I$(KLIBCOBJ)/../include \ + -I$(KLIBCOBJ)/../include \ -I$(KLIBCINC) +ifeq ($(cc-name),clang) +KLIBCCPPFLAGS += -I$(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-file-name=include) +endif + # kernel include paths KLIBCKERNELSRC ?= $(srctree) KLIBCCPPFLAGS += -I$(KLIBCKERNELSRC)/include \ @@ -128,8 +133,8 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \ KLIBCAFLAGS += -D__ASSEMBLY__ -Wa,--noexecstack $(KLIBCCFLAGS) KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note -KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc) -KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF) +KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) $(if $(filter gcc,$(cc-name)),--print-libgcc,--print-libgcc-file-name)) +KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF) KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o KLIBCLIBC := $(KLIBCOBJ)/libc.a KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index 24bad07d..c3ebff99 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -85,8 +85,8 @@ endif # These pass a huge maximum length to the corresponding length-limiting # functions -KLIBCCFLAGS_sprintf.o += -Wno-format-truncation -KLIBCCFLAGS_vsprintf.o += -Wno-format-truncation +KLIBCCFLAGS_sprintf.o += $(call cc-option,-Wno-format-truncation, ) +KLIBCCFLAGS_vsprintf.o += $(call cc-option,-Wno-format-truncation, ) # sigsuspend.c includes <klibc/havesyscall.h> generated by syscalls/ # build, so require that to build first diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG index c5f2fa26..7eed8847 100644 --- a/usr/klibc/arch/x86_64/MCONFIG +++ b/usr/klibc/arch/x86_64/MCONFIG @@ -15,8 +15,10 @@ # debugging using gdb. # KLIBCARCHREQFLAGS = -m64 -KLIBCOPTFLAGS += -Os -fomit-frame-pointer -mno-sse \ - -falign-functions=1 -falign-jumps=1 -falign-loops=1 +KLIBCOPTFLAGS += -Os -fomit-frame-pointer -mno-sse \ + $(call cc-option,-falign-functions=1, ) \ + $(call cc-option,-falign-jumps=1, ) \ + $(call cc-option,-falign-loops=1, ) ifeq ($(DEBUG),y) KLIBCOPTFLAGS += -g else -- 2.26.0.rc2.310.g2932bb562d-goog
Bill Wendling
2020-Mar-29 11:38 UTC
[klibc] [kvm-unit-tests PATCH v3 2/4] Kbuild: support clang's lld
Clang's lld prefers the use of "-image-base" instead of "-Ttext-segment". Signed-off-by: Stanislav Fomichev <sdf at google.com> Signed-off-by: Bill Wendling <morbo at google.com> --- Makefile | 3 +++ usr/klibc/arch/i386/MCONFIG | 2 +- usr/klibc/arch/mips64/MCONFIG | 5 +++-- usr/klibc/arch/ppc/MCONFIG | 2 +- usr/klibc/arch/ppc64/MCONFIG | 2 +- usr/klibc/arch/riscv64/MCONFIG | 2 +- usr/klibc/arch/sparc64/MCONFIG | 2 +- usr/klibc/arch/x86_64/MCONFIG | 2 +- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c99b962f..c8325154 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 LD_IMAGE_BASE_OPT=$(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 07046695..24ae50bc 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 = $(LD_IMAGE_BASE_OPT) 0x06000000 diff --git a/usr/klibc/arch/mips64/MCONFIG b/usr/klibc/arch/mips64/MCONFIG index 6a4b41b2..b35f75b4 100644 --- a/usr/klibc/arch/mips64/MCONFIG +++ b/usr/klibc/arch/mips64/MCONFIG @@ -19,5 +19,6 @@ KLIBCBITSIZE = 64 # 256M aligned region. Since we can't put ourselves below the normal # 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 +# Use -Ttext-segment/--image_base so that the special .MIPS* sections +# are moved as well. +KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x12FE00000 diff --git a/usr/klibc/arch/ppc/MCONFIG b/usr/klibc/arch/ppc/MCONFIG index 8220f6b9..dd239605 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 = $(LD_IMAGE_BASE_OPT) 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 0315110c..be15c32d 100644 --- a/usr/klibc/arch/ppc64/MCONFIG +++ b/usr/klibc/arch/ppc64/MCONFIG @@ -18,7 +18,7 @@ KLIBCBITSIZE = 64 # 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 = $(LD_IMAGE_BASE_OPT) 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 61681509..a6228d85 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 = $(LD_IMAGE_BASE_OPT) 0x00200000 diff --git a/usr/klibc/arch/sparc64/MCONFIG b/usr/klibc/arch/sparc64/MCONFIG index c8339855..459d2217 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 = $(LD_IMAGE_BASE_OPT) 0x80000000 diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG index 7eed8847..2bad5b90 100644 --- a/usr/klibc/arch/x86_64/MCONFIG +++ b/usr/klibc/arch/x86_64/MCONFIG @@ -37,4 +37,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 = $(LD_IMAGE_BASE_OPT) 0x00200000 -z max-page-size=0x1000 -- 2.26.0.rc2.310.g2932bb562d-goog
Bill Wendling
2020-Mar-29 11:38 UTC
[klibc] [kvm-unit-tests PATCH v3 3/4] Kbuild: Add "-fcommon" for clang builds
Clang defaults to "-fno-common" which causes linking errors because of duplicate symbols in the BSS section. Signed-off-by: Bill Wendling <morbo at google.com> --- scripts/Kbuild.klibc | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index ca2539d6..59cc7cf4 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -70,6 +70,7 @@ KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ $(call cc-option, -fwrapv, ) \ $(call cc-option, -fno-PIE, ) \ $(call cc-option, -fno-builtin-bcmp, ) \ + $(call cc-option, -fcommon, ) \ -ggdb KLIBCARCHREQFLAGS : KLIBCOPTFLAGS :-- 2.26.0.rc2.310.g2932bb562d-goog
Bill Wendling
2020-Mar-29 11:38 UTC
[klibc] [kvm-unit-tests PATCH v3 4/4] Clean up clang warnings
Add or remove casts of the "void *" argument of ioctl. Signed-off-by: Bill Wendling <morbo at google.com> --- usr/kinit/initrd.c | 2 +- usr/kinit/ramdisk_load.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/kinit/initrd.c b/usr/kinit/initrd.c index 7eece2ce..5833f2f2 100644 --- a/usr/kinit/initrd.c +++ b/usr/kinit/initrd.c @@ -153,7 +153,7 @@ static int run_linuxrc(int argc, char *argv[], dev_t root_dev) int olddev = open(ramdisk_name, O_RDWR); umount2("/old", MNT_DETACH); if (olddev < 0 || - ioctl(olddev, BLKFLSBUF, (long)0) || + ioctl(olddev, BLKFLSBUF, 0) || close(olddev)) { fprintf(stderr, "%s: Cannot flush initrd contents\n", diff --git a/usr/kinit/ramdisk_load.c b/usr/kinit/ramdisk_load.c index f43339c8..e3e15d81 100644 --- a/usr/kinit/ramdisk_load.c +++ b/usr/kinit/ramdisk_load.c @@ -34,7 +34,7 @@ static int change_disk(const char *devpath, int rfd, int disk) ioctl(rfd, CDROMEJECT, 0); } else { /* Non-ejectable floppy */ - ioctl(rfd, FDRESET, FD_RESET_IF_NEEDED); + ioctl(rfd, FDRESET, (void *)FD_RESET_IF_NEEDED); } } close(rfd); -- 2.26.0.rc2.310.g2932bb562d-goog
Bill Wendling
2020-Mar-29 23:45 UTC
[klibc] [kvm-unit-tests PATCH v3 1/4] Kbuild: add support for clang builds
On Sun, Mar 29, 2020 at 4:38 AM Bill Wendling <morbo at google.com> wrote:> > Add cc-name to klibc/scripts/Kbuild.include. > > Make optimization flags not supported by clang conditional on cc-name. > > Use "--print-file-name=include" and "--print-libgcc-file-name" when > using clang. > > Use cc-option to enable compiler-specific flags. > > Mark "bcmp" as not a builtin to prevent clang from using it. > > Signed-off-by: Bill Wendling <morbo at google.com> > --- > scripts/Kbuild.include | 8 ++++++-- > scripts/Kbuild.klibc | 13 +++++++++---- > usr/klibc/Kbuild | 4 ++-- > usr/klibc/arch/x86_64/MCONFIG | 6 ++++-- > 4 files changed, 21 insertions(+), 10 deletions(-) > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include > index a048ec7a..5604b3e3 100644 > --- a/scripts/Kbuild.include > +++ b/scripts/Kbuild.include > @@ -110,12 +110,12 @@ as-instr = $(call try-run,\ > # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) > > cc-option = $(call try-run,\ > - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) > + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -Werror -c -xc /dev/null -o "$$TMP",$(1),$(2)) > > # cc-option-yn > # Usage: flag := $(call cc-option-yn,-march=winchip-c6) > cc-option-yn = $(call try-run,\ > - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) > + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -Werror -c -xc /dev/null -o "$$TMP",y,n) > > # cc-option-align > # Prefix align with either -falign or -malign > @@ -127,6 +127,10 @@ cc-option-align = $(subst -functions=0,,\ > cc-disable-warning = $(call try-run,\ > $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1))) > > +# cc-name > +# Expands to either gcc or clang > +cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) > + > # cc-version > # Usage gcc-ver := $(call cc-version) > cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) > diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc > index afc9a546..ca2539d6 100644 > --- a/scripts/Kbuild.klibc > +++ b/scripts/Kbuild.klibc > @@ -69,6 +69,7 @@ include $(srctree)/scripts/Kbuild.include > KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ > $(call cc-option, -fwrapv, ) \ > $(call cc-option, -fno-PIE, ) \ > + $(call cc-option, -fno-builtin-bcmp, ) \ > -ggdb > KLIBCARCHREQFLAGS :> KLIBCOPTFLAGS :> @@ -108,10 +109,14 @@ KLIBCOBJDUMP := $(OBJDUMP) > > # klibc include paths > KLIBCCPPFLAGS := -nostdinc -iwithprefix include \ > - -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \ > + -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \ > -I$(KLIBCINC)/bits$(KLIBCBITSIZE) \ > - -I$(KLIBCOBJ)/../include \ > + -I$(KLIBCOBJ)/../include \ > -I$(KLIBCINC) > +ifeq ($(cc-name),clang) > +KLIBCCPPFLAGS += -I$(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-file-name=include) > +endif > + > # kernel include paths > KLIBCKERNELSRC ?= $(srctree) > KLIBCCPPFLAGS += -I$(KLIBCKERNELSRC)/include \ > @@ -128,8 +133,8 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \ > KLIBCAFLAGS += -D__ASSEMBLY__ -Wa,--noexecstack $(KLIBCCFLAGS) > KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note > > -KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc) > -KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF) > +KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) $(if $(filter gcc,$(cc-name)),--print-libgcc,--print-libgcc-file-name))I was doing some late night hacking and just realized that this change is in contradiction to your other email asking that gcc and clang options be placed in separate "ifeq" sections. I was being too clever for my own good. Let me know if you'd like me to submit a v4 of these patches.> +KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF) > KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o > KLIBCLIBC := $(KLIBCOBJ)/libc.a > KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o > diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild > index 24bad07d..c3ebff99 100644 > --- a/usr/klibc/Kbuild > +++ b/usr/klibc/Kbuild > @@ -85,8 +85,8 @@ endif > > # These pass a huge maximum length to the corresponding length-limiting > # functions > -KLIBCCFLAGS_sprintf.o += -Wno-format-truncation > -KLIBCCFLAGS_vsprintf.o += -Wno-format-truncation > +KLIBCCFLAGS_sprintf.o += $(call cc-option,-Wno-format-truncation, ) > +KLIBCCFLAGS_vsprintf.o += $(call cc-option,-Wno-format-truncation, ) > > # sigsuspend.c includes <klibc/havesyscall.h> generated by syscalls/ > # build, so require that to build first > diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG > index c5f2fa26..7eed8847 100644 > --- a/usr/klibc/arch/x86_64/MCONFIG > +++ b/usr/klibc/arch/x86_64/MCONFIG > @@ -15,8 +15,10 @@ > # debugging using gdb. > # > KLIBCARCHREQFLAGS = -m64 > -KLIBCOPTFLAGS += -Os -fomit-frame-pointer -mno-sse \ > - -falign-functions=1 -falign-jumps=1 -falign-loops=1 > +KLIBCOPTFLAGS += -Os -fomit-frame-pointer -mno-sse \ > + $(call cc-option,-falign-functions=1, ) \ > + $(call cc-option,-falign-jumps=1, ) \ > + $(call cc-option,-falign-loops=1, ) > ifeq ($(DEBUG),y) > KLIBCOPTFLAGS += -g > else > -- > 2.26.0.rc2.310.g2932bb562d-goog >
Ben Hutchings
2020-Jul-25 16:47 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
On Sun, 2020-03-29 at 04:38 -0700, Bill Wendling wrote:> - Renamed IMAGE_BASE to LD_IMAGE_BASE_OPT. > - Moved "-fcommon" to KLIBCREQFLAGS in scripts/Kbuild.klibc. > - Remove "dash" warning fixes which have been upstreamed. > - Conditionalize the inclusion of compiler flags by using the proper > compiler name or "cc-option". > - Added "-Werror" to "cc-option" to catch flags that cause warnings. > - Retain "-nostdinc -iwithprefix include" and use the proper clang flag > to get the path to find "stdarg.h". > - Move "-fno-builtin-bcmp" to KLIBCREQFLAGS in scripts/Kbuild.klibc.I'm just going to apply this series now, and we can worry about cleaning up the FLAGS variable definitions later. Thanks for your patience, Ben.> Bill Wendling (4): > [klibc] Kbuild: add support for clang builds > [klibc] Kbuild: support clang's lld > [klibc] Kbuild: Add "-fcommon" for clang builds > [klibc] Clean up clang warnings > > Makefile | 3 +++ > scripts/Kbuild.include | 8 ++++++-- > scripts/Kbuild.klibc | 14 ++++++++++---- > usr/kinit/initrd.c | 2 +- > usr/kinit/ramdisk_load.c | 2 +- > usr/klibc/Kbuild | 4 ++-- > usr/klibc/arch/i386/MCONFIG | 2 +- > usr/klibc/arch/mips64/MCONFIG | 5 +++-- > usr/klibc/arch/ppc/MCONFIG | 2 +- > usr/klibc/arch/ppc64/MCONFIG | 2 +- > usr/klibc/arch/riscv64/MCONFIG | 2 +- > usr/klibc/arch/sparc64/MCONFIG | 2 +- > usr/klibc/arch/x86_64/MCONFIG | 8 +++++--- > 13 files changed, 36 insertions(+), 20 deletions(-) >-- Ben Hutchings Anthony's Law of Force: Don't force it, get a larger hammer. -------------- 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/20200725/71e3c041/attachment.sig>
Ben Hutchings
2020-Jul-25 20:57 UTC
[klibc] [kvm-unit-tests PATCH v3 0/4] Update patch set
On Sat, 2020-07-25 at 17:47 +0100, Ben Hutchings wrote:> On Sun, 2020-03-29 at 04:38 -0700, Bill Wendling wrote: > > - Renamed IMAGE_BASE to LD_IMAGE_BASE_OPT. > > - Moved "-fcommon" to KLIBCREQFLAGS in scripts/Kbuild.klibc. > > - Remove "dash" warning fixes which have been upstreamed. > > - Conditionalize the inclusion of compiler flags by using the proper > > compiler name or "cc-option". > > - Added "-Werror" to "cc-option" to catch flags that cause warnings. > > - Retain "-nostdinc -iwithprefix include" and use the proper clang flag > > to get the path to find "stdarg.h". > > - Move "-fno-builtin-bcmp" to KLIBCREQFLAGS in scripts/Kbuild.klibc. > > I'm just going to apply this series now, and we can worry about > cleaning up the FLAGS variable definitions later. > > Thanks for your patience,[...] Unfortunately this doesn't work with Clang and lld 9.0.1. Clang is now optimising some stdio calls to their _unlocked variants, which we don't define. I added definitions of all those, and was then able to able to build everything with Clang and ld.bfd. I've pushed that change following these patches. However, when I use Clang and ld.lld, it fails to link dynamically- linked programs: ld.lld: error: undefined symbol: gettimeofday >>> referenced by main.c:842 (usr/kinit/ipconfig/main.c:842) >>> usr/kinit/ipconfig/main.o:(ipconfig_main) >>> referenced by main.c:446 (usr/kinit/ipconfig/main.c:446) >>> usr/kinit/ipconfig/main.o:(ipconfig_main) >>> referenced by main.c:490 (usr/kinit/ipconfig/main.c:490) >>> usr/kinit/ipconfig/main.o:(ipconfig_main) ld.lld: error: undefined symbol: srand48 >>> referenced by main.c:843 (usr/kinit/ipconfig/main.c:843) >>> usr/kinit/ipconfig/main.o:(ipconfig_main) ld.lld: error: undefined symbol: setjmp >>> referenced by main.c:846 (usr/kinit/ipconfig/main.c:846) >>> usr/kinit/ipconfig/main.o:(ipconfig_main) [...] Ben. -- Ben Hutchings Anthony's Law of Force: Don't force it, get a larger hammer. -------------- 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/20200725/d132d43a/attachment.sig>