Page MenuHomeFreeBSD

bsd.compiler.mk: detect Apple Clang for cross-builds
ClosedPublic

Authored by arichardson on Apr 9 2021, 4:59 PM.

Details

Summary

Apple clang uses a different versioning scheme, so if we enable or
disable certain warnings for Clang 11+, those might not be supported
in Apple Clang 11+. This adds 'apple-clang' to COMPILER_FEATURES, so that
bootstrap tools Makefiles can avoid warnings on macOS.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

share/mk/bsd.compiler.mk
186

Probably better off with an ${X_}CLANG_TYPE? Otherwise you'll have to use :M*clang in a load of places.

216โ€“217

๐Ÿ‘€

jrtc27 retitled this revision from [UPSTREAM] bsd.compiler.mk: detect Apple Clang for cross-builds to bsd.compiler.mk: detect Apple Clang for cross-builds.Apr 9 2021, 5:01 PM
share/mk/bsd.compiler.mk
186

That could also work. I just noticed the warning that is causing issues is a CheriBSD-local diff, so we might not need this after all.

216โ€“217

oops had some debugging .info statements here.

share/mk/bsd.compiler.mk
185

IMO we should explicitly mention Apple's versioning scheme to explain why there's a special apple-clang. Is there some site that cross-references Apple and upstream Clang revisions?

share/mk/bsd.compiler.mk
185

Wikipedia has a table at https://en.wikipedia.org/wiki/Xcode#Toolchain_versions which ultimately just gets the information from Apple's Swift LLVM fork via e.g. https://github.com/apple/llvm-project/blob/swift-5.3.2-RELEASE/llvm/CMakeLists.txt.

Use COMPILER_FEATURES instead

The new version uses COMPILER_FEATURES instead.

bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 253: COMPILER_FEATURES=apple-clang c++11 c++14 c++17 retpoline init-all
bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 254: COMPILER_TYPE=clang
bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 255: COMPILER_VERSION=120000
bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 256: X_COMPILER_FEATURES=c++11 c++14 c++17 retpoline init-all
bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 257: X_COMPILER_TYPE=clang
bmake[2]: "/Users/alex/cheri/cheribsd/share/mk/bsd.compiler.mk" line 258: X_COMPILER_VERSION=130000

This looks good as is, though I'd be inclined to use += in the place I tagged to future proof.

share/mk/bsd.compiler.mk
212

Do you want to use = or += here?

This revision is now accepted and ready to land.Apr 15 2021, 2:53 PM
share/mk/bsd.compiler.mk
212

Good point, might as well use += everywhere. Will make that change before committing

share/mk/bsd.compiler.mk
212

Looking at it again, it's guarded by !defined(${X_}COMPILER_FEATURES) so assigning might make more sense than using +=

share/mk/bsd.compiler.mk
212

Sounds good to me then. I hadn't noticed that would make = fine.