diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn --- a/llvm/utils/gn/build/BUILD.gn +++ b/llvm/utils/gn/build/BUILD.gn @@ -1,5 +1,6 @@ import("//llvm/utils/gn/build/buildflags.gni") import("//llvm/utils/gn/build/mac_sdk.gni") +import("//llvm/utils/gn/build/sysroot.gni") import("//llvm/utils/gn/build/toolchain/compiler.gni") import("//llvm/utils/gn/build/toolchain/target_flags.gni") @@ -22,9 +23,6 @@ # The version of host gcc. Ignored if is_clang is true. gcc_version = 9 - - # Path of sysroot to use. - sysroot = "" } assert(!llvm_build_instrumented_coverage || is_clang, @@ -292,6 +290,9 @@ cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ] } else { cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ] + if (is_clang) { + cflags += [ "-Wpoison-system-directories"] + } } } diff --git a/llvm/utils/gn/build/libs/xml/BUILD.gn b/llvm/utils/gn/build/libs/xml/BUILD.gn --- a/llvm/utils/gn/build/libs/xml/BUILD.gn +++ b/llvm/utils/gn/build/libs/xml/BUILD.gn @@ -1,5 +1,6 @@ import("//llvm/utils/gn/build/libs/xml/enable.gni") import("//llvm/utils/gn/build/mac_sdk.gni") +import("//llvm/utils/gn/build/sysroot.gni") config("xml_config") { visibility = [ ":xml" ] @@ -7,7 +8,7 @@ if (host_os == "mac") { include_dirs = [ "$mac_sdk_path/usr/include/libxml2" ] } else { - include_dirs = [ "/usr/include/libxml2" ] + include_dirs = [ "$sysroot/usr/include/libxml2" ] } } diff --git a/llvm/utils/gn/build/sysroot.gni b/llvm/utils/gn/build/sysroot.gni new file mode 100644 --- /dev/null +++ b/llvm/utils/gn/build/sysroot.gni @@ -0,0 +1,4 @@ +declare_args() { + # Path of sysroot to use. + sysroot = "" +}