> Date: Mon, 25 Oct 2021 12:01:11 +0200
> From: Patrick Wildt <[email protected]>
> 
> Hi,
> 
> mortimer@ has this diff in his tree for LLVM 13.  I actually haven't
> tried to see if it works fine with LLVM 11, but I feel it needs to be
> sent out and not just be blindly committed.
> 
> If someone wants to take care of this, it would be nice, so I can take
> care of the remaining parts of sending out the LLVM 13 diff.

Some explanation on -Wno-unused-but-set-variable and
-Wno-null-pointer-subtraction and -Wno-gnu-folding-constant would be
useful.  I doubt base gcc supports these so we may need to add these
only when building with clang.  Or maybe disable these by default?  Or
should we fix the code instead?

I guess non-amd64 arhcitectures need some love too...


> diff --git a/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper 
> b/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper
> index 611a2169862..f4c4e224dc5 100644
> --- a/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper
> +++ b/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper
> @@ -7,7 +7,7 @@ TARGET_ARCH?= ${MACHINE_ARCH}
>  SUBDIRS=     opcodes bfd
>  CONF_SUBDIRS=        opcodes bfd
>  
> -CFLAGS+=     ${PIE_DEFAULT}
> +CFLAGS+=     ${PIE_DEFAULT} -Wno-unused-but-set-variable 
> -Wno-null-pointer-subtraction
>  XCFLAGS=     CC="${CC}" CFLAGS="${CFLAGS} ${COPTS}" LDFLAGS="${LDSTATIC}"
>  # This allows moving the whole binutils installation around for 
>  # testing purposes
> diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c
> index a4a7cd19fce..41500fc1442 100644
> --- a/lib/csu/crtbeginS.c
> +++ b/lib/csu/crtbeginS.c
> @@ -85,6 +85,7 @@ int _thread_atfork(void (*)(void), void (*)(void), void 
> (*)(void), void *)
>           __attribute__((weak));
>  
>  int
> +__attribute__((weak))
>  pthread_atfork(void (*prep)(void), void (*parent)(void), void (*child)(void))
>  {
>       return (_thread_atfork(prep, parent, child, &__dso_handle));

Hmm, so in -current this function isn't actually weak.  Not sure I
fully understand the consequences of that.


> diff --git a/lib/libc/arch/amd64/sys/brk.S b/lib/libc/arch/amd64/sys/brk.S
> index ce69679e389..ee1c11f7643 100644
> --- a/lib/libc/arch/amd64/sys/brk.S
> +++ b/lib/libc/arch/amd64/sys/brk.S
> @@ -48,7 +48,6 @@ __minbrk:
>       END(__minbrk)
>       .type   __minbrk,@object
>  
> -     .weak   brk
>  ENTRY(brk)
>       cmpq    %rdi,__minbrk(%rip)
>       jb      1f
> diff --git a/lib/libc/arch/amd64/sys/sbrk.S b/lib/libc/arch/amd64/sys/sbrk.S
> index 8d7d68909b2..db53a6bb643 100644
> --- a/lib/libc/arch/amd64/sys/sbrk.S
> +++ b/lib/libc/arch/amd64/sys/sbrk.S
> @@ -53,7 +53,6 @@ __curbrk:
>       END(__curbrk)
>       .type   __curbrk,@object
>  
> -     .weak   sbrk
>  ENTRY(sbrk)
>       movq    __curbrk(%rip),%rax
>       movslq  %edi,%rsi

These functions are supposed to be weak, like they are on
architectures that use a C implementation.  I suppose the .weak
directive needs to come *after* the .global emitted by ENTRY().
Putting it after the END() works.

> diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile
> index 1a3a3888352..f6063ffb194 100644
> --- a/lib/libcrypto/Makefile
> +++ b/lib/libcrypto/Makefile
> @@ -16,7 +16,7 @@ LCRYPTO_SRC=        ${.CURDIR}
>  
>  CFLAGS+= -Wall -Wundef
>  .if ${COMPILER_VERSION:L} == "clang"
> -CFLAGS+= -Werror
> +CFLAGS+= -Werror -Wno-unused-but-set-variable
>  .endif
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
> diff --git a/sys/arch/amd64/conf/Makefile.amd64 
> b/sys/arch/amd64/conf/Makefile.amd64
> index d36bae30417..83bd9a9fed1 100644
> --- a/sys/arch/amd64/conf/Makefile.amd64
> +++ b/sys/arch/amd64/conf/Makefile.amd64
> @@ -70,7 +70,8 @@ CMACHFLAGS+=        -mno-retpoline
>  .endif
>  .if ${COMPILER_VERSION:Mclang}
>  NO_INTEGR_AS=        -no-integrated-as
> -CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion
> +CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion \
> +     -Wno-unused-but-set-variable -Wno-gnu-folding-constant
>  .endif
>  
>  DEBUG?=              -g
> diff --git a/sys/arch/amd64/stand/pxeboot/Makefile 
> b/sys/arch/amd64/stand/pxeboot/Makefile
> index 9b028d8f4aa..cc92233463b 100644
> --- a/sys/arch/amd64/stand/pxeboot/Makefile
> +++ b/sys/arch/amd64/stand/pxeboot/Makefile
> @@ -71,7 +71,7 @@ CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} 
> -DLINKADDR=${LINKADDR}
>  CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE 
> -DBUILDFIXED
>  CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
>  CFLAGS+=-m32
> -CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
> +CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie 
> -Wno-unused-but-set-variable
>  AFLAGS+=${NO_INTEGR_AS}
>  # AFLAGS+=-Wa,-a
>  AFLAGS+=-m32 # -Wa,-R
> diff --git a/usr.bin/openssl/Makefile b/usr.bin/openssl/Makefile
> index 664a5200037..e33763e7420 100644
> --- a/usr.bin/openssl/Makefile
> +++ b/usr.bin/openssl/Makefile
> @@ -17,6 +17,7 @@ CFLAGS+= -Wuninitialized
>  CFLAGS+= -Wunused
>  .if ${COMPILER_VERSION:L} == "clang"
>  CFLAGS+= -Werror
> +CFLAGS+= -Wno-unused-but-set-variable
>  .endif
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
> diff --git a/sys/arch/amd64/conf/Makefile.amd64 
> b/sys/arch/amd64/conf/Makefile.amd64
> index d36bae30417..83bd9a9fed1 100644
> --- a/sys/arch/amd64/conf/Makefile.amd64
> +++ b/sys/arch/amd64/conf/Makefile.amd64
> @@ -70,7 +70,8 @@ CMACHFLAGS+=        -mno-retpoline
>  .endif
>  .if ${COMPILER_VERSION:Mclang}
>  NO_INTEGR_AS=        -no-integrated-as
> -CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion
> +CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion \
> +     -Wno-unused-but-set-variable -Wno-gnu-folding-constant
>  .endif
>  
>  DEBUG?=              -g
> diff --git a/sys/arch/amd64/stand/pxeboot/Makefile 
> b/sys/arch/amd64/stand/pxeboot/Makefile
> index 9b028d8f4aa..cc92233463b 100644
> --- a/sys/arch/amd64/stand/pxeboot/Makefile
> +++ b/sys/arch/amd64/stand/pxeboot/Makefile
> @@ -71,7 +71,7 @@ CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} 
> -DLINKADDR=${LINKADDR}
>  CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE 
> -DBUILDFIXED
>  CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
>  CFLAGS+=-m32
> -CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
> +CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie 
> -Wno-unused-but-set-variable
>  AFLAGS+=${NO_INTEGR_AS}
>  # AFLAGS+=-Wa,-a
>  AFLAGS+=-m32 # -Wa,-R
> 
> 

Reply via email to