svn commit: r359681 - in head: . share/mk
Bryan Drewery
bdrewery at FreeBSD.org
Tue Apr 7 01:49:34 UTC 2020
On 4/6/2020 4:38 PM, Brooks Davis wrote:
> Author: brooks
> Date: Mon Apr 6 23:38:46 2020
> New Revision: 359681
> URL: https://svnweb.freebsd.org/changeset/base/359681
>
> Log:
> Fix compilation with upstream clang builtin headers.
>
> By using -nobuiltininc and adding the clang builtin headers resource dir
> to the end of the compiler header search path, we can still find headers
> such as immintrin.h but find the FreeBSD version of stddef.h/stdarg.h/..
> first.
>
> This is a workaround until we are able to settle on and complete a plan
> to harmonize guard macros with LLVM. We've mostly worked out this on
> FreeBSD systems by removing select headers from the installed set of
> devel/llvm*, but that isn't a good solution for cross build.
>
> Submitted by: arichardson
> Obtained from: CheriBSD
> Sponsored by: DARPA, AFRL
> Differential Revision: https://reviews.freebsd.org/D17002
>
> Modified:
> head/Makefile.inc1
> head/share/mk/bsd.compiler.mk
> head/share/mk/bsd.sys.mk
>
> Modified: head/Makefile.inc1
> ==============================================================================
> --- head/Makefile.inc1 Mon Apr 6 23:28:24 2020 (r359680)
> +++ head/Makefile.inc1 Mon Apr 6 23:38:46 2020 (r359681)
> @@ -337,6 +337,7 @@ _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
> COMPILER_TYPE \
> COMPILER_FEATURES \
> COMPILER_FREEBSD_VERSION \
> + COMPILER_RESOURCE_DIR \
> LINKER_VERSION \
> LINKER_FEATURES \
> LINKER_TYPE \
>
> Modified: head/share/mk/bsd.compiler.mk
> ==============================================================================
> --- head/share/mk/bsd.compiler.mk Mon Apr 6 23:28:24 2020 (r359680)
> +++ head/share/mk/bsd.compiler.mk Mon Apr 6 23:38:46 2020 (r359681)
> @@ -143,7 +143,7 @@ _cc_vars+=XCC X_
> # The value is only used/exported for the same environment that impacts
> # CC and COMPILER_* settings here.
> _exported_vars= ${X_}COMPILER_TYPE ${X_}COMPILER_VERSION \
> - ${X_}COMPILER_FREEBSD_VERSION
> + ${X_}COMPILER_FREEBSD_VERSION ${X_}COMPILER_RESOURCE_DIR
> ${X_}_cc_hash= ${${cc}}${MACHINE}${PATH}
> ${X_}_cc_hash:= ${${X_}_cc_hash:hash}
> # Only import if none of the vars are set somehow else.
> @@ -201,6 +201,10 @@ ${X_}COMPILER_FREEBSD_VERSION= unknown
> .endif
> .endif
>
> +.if !defined(${X_}COMPILER_RESOURCE_DIR)
> +${X_}COMPILER_RESOURCE_DIR!= ${${cc}:N${CCACHE_BIN}} -print-resource-dir 2>/dev/null || echo unknown
> +.endif
> +
> ${X_}COMPILER_FEATURES=
> .if (${${X_}COMPILER_TYPE} == "clang" && ${${X_}COMPILER_VERSION} >= 30300) || \
> (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 40800)
> @@ -224,6 +228,7 @@ X_COMPILER_TYPE= ${COMPILER_TYPE}
> X_COMPILER_VERSION= ${COMPILER_VERSION}
> X_COMPILER_FREEBSD_VERSION= ${COMPILER_FREEBSD_VERSION}
> X_COMPILER_FEATURES= ${COMPILER_FEATURES}
> +X_COMPILER_RESOURCE_DIR= ${COMPILER_RESOURCE_DIR}
> .endif # ${cc} == "CC" || (${cc} == "XCC" && ${XCC} != ${CC})
>
> # Export the values so sub-makes don't have to look them up again, using the
>
> Modified: head/share/mk/bsd.sys.mk
> ==============================================================================
> --- head/share/mk/bsd.sys.mk Mon Apr 6 23:28:24 2020 (r359680)
> +++ head/share/mk/bsd.sys.mk Mon Apr 6 23:38:46 2020 (r359681)
> @@ -206,6 +206,21 @@ CWARNFLAGS+= -Wno-unknown-pragmas
> # This warning is utter nonsense
> CFLAGS+= -Wno-format-zero-length
>
> +.if ${COMPILER_TYPE} == "clang"
> +# The headers provided by clang are incompatible with the FreeBSD headers.
> +# If the version of clang is not one that has been patched to omit the
> +# incompatible headers, we need to compile with -nobuiltininc and add the
> +# resource dir to the end of the search paths. This ensures that headers such as
> +# immintrin.h are still found but stddef.h, etc. are picked up from FreeBSD.
> +#
> +# XXX: This is a hack to support complete external installs of clang while
> +# we work to synchronize our decleration guards with those in the clang tree.
> +.if ${MK_CLANG_BOOTSTRAP} == "no" && ${COMPILER_RESOURCE_DIR} != "unknown" && \
> + !defined(BOOTSTRAPPING)
I just realized MK_CLANG_BOOTSTRAP is not going to be defined here
outside of the tree. Adding :Uno will fix it. Keep in mind this current
change and the next will affect ports. It looks like by default clang
will always get these flags added on.
> +CFLAGS+=-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include
> +.endif
> +.endif
> +
> CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
> -mllvm -simplifycfg-dup-ret
> .if ${COMPILER_VERSION} >= 30500 && ${COMPILER_VERSION} < 30700
>
--
Regards,
Bryan Drewery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 618 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20200406/933df8da/attachment-0001.sig>
More information about the svn-src-head
mailing list