[PATCH] D138183: [Driver] move FreeBSD header search path management to the driver

Matt Jacobson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 16 23:56:48 PST 2022


mhjacobson added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/FreeBSD.cpp:442
+
+  addExternCSystemInclude(DriverArgs, CC1Args,
+                          concat(D.SysRoot, "/usr/include"));
----------------
MaskRay wrote:
> I think Fuchsia way of checking `if (!D.SysRoot.empty()) {` before adding `/usr/include` is probably better. Is it /include or /usr/include ?
It's `/usr/include` on FreeBSD.

I'm confused by the Fuchsia code—does it not add `/include` if the sysroot is empty?  Appears not...

```
$ clang-15 -### -c -target arm64-fuchsia -xc /dev/null         
clang version 15.0.3
Target: arm64-unknown-fuchsia
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-15/bin
 (in-process)
 "/opt/local/libexec/llvm-15/bin/clang" "-cc1" "-triple" "arm64-unknown-fuchsia" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "null" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v8a" "-target-abi" "aapcs" "-fallow-half-arguments-and-returns" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" "-target-linker-version" "556.6" "-fcoverage-compilation-dir=/Users/matt" "-resource-dir" "/opt/local/libexec/llvm-15/lib/clang/15.0.3" "-I/usr/local/include" "-internal-isystem" "/opt/local/libexec/llvm-15/lib/clang/15.0.3/include" "-fdebug-compilation-dir=/Users/matt" "-ferror-limit" "19" "-fsanitize=shadow-call-stack" "-stack-protector" "2" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-target-feature" "+outline-atomics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "null.o" "-x" "c" "/dev/null"

$ clang-15 -### -c -target arm64-fuchsia --sysroot /foo -xc /dev/null
clang version 15.0.3
Target: arm64-unknown-fuchsia
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-15/bin
 (in-process)
 "/opt/local/libexec/llvm-15/bin/clang" "-cc1" "-triple" "arm64-unknown-fuchsia" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "null" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v8a" "-target-abi" "aapcs" "-fallow-half-arguments-and-returns" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" "-target-linker-version" "556.6" "-fcoverage-compilation-dir=/Users/matt" "-resource-dir" "/opt/local/libexec/llvm-15/lib/clang/15.0.3" "-isysroot" "/foo" "-internal-isystem" "/opt/local/libexec/llvm-15/lib/clang/15.0.3/include" "-internal-externc-isystem" "/foo/include" "-fdebug-compilation-dir=/Users/matt" "-ferror-limit" "19" "-fsanitize=shadow-call-stack" "-stack-protector" "2" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-target-feature" "+outline-atomics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "null.o" "-x" "c" "/dev/null"
```

I don't know anything about Fuchsia, but isn't that wrong?  Certainly for FreeBSD we'd want to add an unprefixed `/usr/include` normally...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138183/new/

https://reviews.llvm.org/D138183



More information about the cfe-commits mailing list