[flang-commits] [flang] [clang] [flang][driver] Add support for -isysroot in the frontend (PR #77365)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Tue Jan 9 06:24:27 PST 2024


================
@@ -0,0 +1,12 @@
+! Verify that the -isysroot flag is known to the frontend and, on Darwin,
+! is passed on to the linker.
+
+! RUN: %flang -### --target=aarch64-apple-darwin -isysroot /path/to/sysroot \
+! RUN:        %s 2>&1 | FileCheck %s --check-prefix=CHECK-DARWIN
+! RUN: %flang -### --target=aarch64-linux-gnu -isysroot /path/to/sysroot \
+! RUN:        %s 2>&1 | FileCheck %s --check-prefix=CHECK-LINUX
+
+! CHECK-DARWIN: "{{.*[\/]}}ld" {{.*}}"-syslibroot" "/path/to/sysroot"
+! Unused on Linux.
+! CHECK-LINUX: warning: argument unused during compilation: '-isysroot /path/to/sysroot'
----------------
luporl wrote:

With clang the behavior of `-isysroot` is also different on Darwin. The man page of gcc explains it better:
```
    This option is like the --sysroot option, but applies only to
    header files (except for Darwin targets, where it applies to
    both header files and libraries).
```

As Fortran doesn't use header files (at least not by default), `-isysroot` ends up unused on other targets.

I guess we could use `--sysroot` instead, but I wanted to match what our build system does when building C/C++ sources with clang, which is use `-isysroot` on Darwin.

https://github.com/llvm/llvm-project/pull/77365


More information about the flang-commits mailing list