Lines Matching +full:llvm +full:- +full:config
1 //! Compilation of native dependencies like LLVM.
3 //! Native projects like LLVM unfortunately aren't suited just yet for
6 //! compile LLVM 3 times as part of a normal bootstrap (we want it cached).
8 //! LLVM and compiler-rt are essentially just wired up to everything else to
21 use crate::config::{Config, TargetSelection};
30 /// Path to llvm-config binary.
31 /// NB: This is always the host llvm-config!
33 /// Path to LLVM cmake directory for the target.
44 // Linker flags to pass to LLVM's CMake invocation.
67 /// This returns whether we've already previously built LLVM.
69 /// It's used to avoid busting caches during x.py check -- if we've already built
70 /// LLVM, it's fine for us to not try to avoid doing so.
72 /// This will return the llvm-config if it can get it (but it will not build it
77 ) -> Result<LlvmResult, Meta> { in prebuilt_llvm_config()
78 builder.config.maybe_download_ci_llvm(); in prebuilt_llvm_config()
80 // If we're using a custom LLVM bail out here, but we can only use a in prebuilt_llvm_config()
81 // custom LLVM for the build triple. in prebuilt_llvm_config()
82 if let Some(config) = builder.config.target_config.get(&target) { in prebuilt_llvm_config()
83 if let Some(ref s) = config.llvm_config { in prebuilt_llvm_config()
91 llvm_cmake_dir.push("llvm"); in prebuilt_llvm_config()
96 let root = "src/llvm-project/llvm"; in prebuilt_llvm_config()
99 let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build); in prebuilt_llvm_config()
100 if !builder.config.build.contains("msvc") || builder.ninja() { in prebuilt_llvm_config()
104 let build_llvm_config = llvm_config_ret_dir.join(exe("llvm-config", builder.config.build)); in prebuilt_llvm_config()
105 let llvm_cmake_dir = out_dir.join("lib/cmake/llvm"); in prebuilt_llvm_config()
108 let stamp = out_dir.join("llvm-finished-building"); in prebuilt_llvm_config()
114 "Could not determine the LLVM submodule commit hash. \ in prebuilt_llvm_config()
115 Assuming that an LLVM rebuild is not necessary.", in prebuilt_llvm_config()
118 "To force LLVM to rebuild, remove the file `{}`", in prebuilt_llvm_config()
128 /// This retrieves the LLVM sha we *want* to use, according to git history.
129 pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String { in detect_llvm_sha() argument
131 let mut rev_list = config.git(); in detect_llvm_sha()
133 PathBuf::from("rev-list"), in detect_llvm_sha()
134 format!("--author={}", config.stage0_metadata.config.git_merge_commit_email).into(), in detect_llvm_sha()
135 "-n1".into(), in detect_llvm_sha()
136 "--first-parent".into(), in detect_llvm_sha()
138 "--".into(), in detect_llvm_sha()
139 config.src.join("src/llvm-project"), in detect_llvm_sha()
140 config.src.join("src/bootstrap/download-ci-llvm-stamp"), in detect_llvm_sha()
141 // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly` in detect_llvm_sha()
142 config.src.join("src/version"), in detect_llvm_sha()
145 } else if let Some(info) = channel::read_commit_info_file(&config.src) { in detect_llvm_sha()
152 eprintln!("error: could not find commit hash for downloading LLVM"); in detect_llvm_sha()
154 eprintln!("help: consider disabling `download-ci-llvm`"); in detect_llvm_sha()
162 /// Returns whether the CI-found LLVM is currently usable.
165 /// and then verifies if the current HEAD matches the detected LLVM SHA head,
166 /// in which case LLVM is indicated as not available.
167 pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool { in is_ci_llvm_available() argument
170 // https://doc.rust-lang.org/rustc/platform-support.html#tier-1 in is_ci_llvm_available()
173 ("aarch64-unknown-linux-gnu", false), in is_ci_llvm_available()
174 ("i686-pc-windows-gnu", false), in is_ci_llvm_available()
175 ("i686-pc-windows-msvc", false), in is_ci_llvm_available()
176 ("i686-unknown-linux-gnu", false), in is_ci_llvm_available()
177 ("x86_64-unknown-linux-gnu", true), in is_ci_llvm_available()
178 ("x86_64-apple-darwin", true), in is_ci_llvm_available()
179 ("x86_64-pc-windows-gnu", true), in is_ci_llvm_available()
180 ("x86_64-pc-windows-msvc", true), in is_ci_llvm_available()
182 ("aarch64-apple-darwin", false), in is_ci_llvm_available()
183 ("aarch64-pc-windows-msvc", false), in is_ci_llvm_available()
184 ("aarch64-unknown-linux-musl", false), in is_ci_llvm_available()
185 ("arm-unknown-linux-gnueabi", false), in is_ci_llvm_available()
186 ("arm-unknown-linux-gnueabihf", false), in is_ci_llvm_available()
187 ("armv7-unknown-linux-gnueabihf", false), in is_ci_llvm_available()
188 ("loongarch64-unknown-linux-gnu", false), in is_ci_llvm_available()
189 ("mips-unknown-linux-gnu", false), in is_ci_llvm_available()
190 ("mips64-unknown-linux-gnuabi64", false), in is_ci_llvm_available()
191 ("mips64el-unknown-linux-gnuabi64", false), in is_ci_llvm_available()
192 ("mipsel-unknown-linux-gnu", false), in is_ci_llvm_available()
193 ("powerpc-unknown-linux-gnu", false), in is_ci_llvm_available()
194 ("powerpc64-unknown-linux-gnu", false), in is_ci_llvm_available()
195 ("powerpc64le-unknown-linux-gnu", false), in is_ci_llvm_available()
196 ("riscv64gc-unknown-linux-gnu", false), in is_ci_llvm_available()
197 ("s390x-unknown-linux-gnu", false), in is_ci_llvm_available()
198 ("x86_64-unknown-freebsd", false), in is_ci_llvm_available()
199 ("x86_64-unknown-illumos", false), in is_ci_llvm_available()
200 ("x86_64-unknown-linux-musl", false), in is_ci_llvm_available()
201 ("x86_64-unknown-netbsd", false), in is_ci_llvm_available()
204 if !supported_platforms.contains(&(&*config.build.triple, asserts)) { in is_ci_llvm_available()
205 if asserts == true || !supported_platforms.contains(&(&*config.build.triple, true)) { in is_ci_llvm_available()
210 if is_ci_llvm_modified(config) { in is_ci_llvm_available()
211 eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change"); in is_ci_llvm_available()
218 /// Returns true if we're running in CI with modified LLVM (and thus can't download it)
219 pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool { in is_ci_llvm_modified()
220 CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() && { in is_ci_llvm_modified()
223 let llvm_sha = detect_llvm_sha(config, true); in is_ci_llvm_modified()
224 let head_sha = output(config.git().arg("rev-parse").arg("HEAD")); in is_ci_llvm_modified()
231 pub struct Llvm { struct
235 impl Step for Llvm { implementation
240 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { in should_run()
241 run.path("src/llvm-project").path("src/llvm-project/llvm") in should_run()
245 run.builder.ensure(Llvm { target: run.target }); in make_run()
248 /// Compile LLVM for `target`.
249 fn run(self, builder: &Builder<'_>) -> LlvmResult { in run()
252 // RISC-V target triples in Rust is not named the same as C compiler target triples. in run()
253 // This converts Rust RISC-V target triples to C compiler triples. in run()
254 let idx = target.triple.find('-').unwrap(); in run()
270 builder.update_submodule(&Path::new("src").join("llvm-project")); in run()
272 panic!("shared linking to LLVM is not currently supported on {}", target.triple); in run()
275 let _guard = builder.msg_unstaged(Kind::Build, "LLVM", target); in run()
280 // https://llvm.org/docs/CMake.html in run()
281 let mut cfg = cmake::Config::new(builder.src.join(root)); in run()
284 let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) { in run()
290 // NOTE: remember to also update `config.example.toml` when changing the in run()
292 let llvm_targets = match &builder.config.llvm_targets { in run()
300 let llvm_exp_targets = match builder.config.llvm_experimental_targets { in run()
305 let assertions = if builder.config.llvm_assertions { "ON" } else { "OFF" }; in run()
306 let plugins = if builder.config.llvm_plugins { "ON" } else { "OFF" }; in run()
307 let enable_tests = if builder.config.llvm_tests { "ON" } else { "OFF" }; in run()
308 let enable_warnings = if builder.config.llvm_enable_warnings { "ON" } else { "OFF" }; in run()
326 .define("LLVM_TARGET_ARCH", target_native.split('-').next().unwrap()) in run()
331 // `build/$TARGET/llvm/build/bin` is but *not* then installed to `build/$TARGET/llvm/bin`. in run()
335 if builder.config.llvm_profile_generate { in run()
342 if let Some(path) = builder.config.llvm_profile_use.as_ref() { in run()
345 if builder.config.llvm_bolt_profile_generate in run()
346 || builder.config.llvm_bolt_profile_use.is_some() in run()
349 ldflags.push_all("-Wl,-q"); in run()
362 if target.contains("apple-ios") in run()
363 || target.contains("apple-tvos") in run()
364 || target.contains("apple-watchos") in run()
369 …// Prevent cmake from adding -bundle to CFLAGS automatically, which leads to a compiler error beca… in run()
375 // This setting makes the LLVM tools link to the dynamic LLVM library, in run()
388 // RISC-V GCC erroneously requires linking against in run()
389 // `libatomic` when using 1-byte and 2-byte C++ in run()
390 // atomics but the LLVM build system check cannot in run()
395 ldflags.exe.push(" -latomic"); in run()
396 ldflags.shared.push(" -latomic"); in run()
414 enabled_llvm_projects.push("compiler-rt"); in run()
417 if builder.config.llvm_polly { in run()
421 if builder.config.llvm_clang { in run()
426 // See https://github.com/rust-lang/rust/pull/50104 in run()
435 if let Some(num_linkers) = builder.config.llvm_link_jobs { in run()
441 // https://llvm.org/docs/HowToCrossCompileLLVM.html in run()
442 if target != builder.config.build { in run()
444 builder.ensure(Llvm { target: builder.config.build }); in run()
445 if !builder.config.dry_run() { in run()
446 let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); in run()
450 host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION), in run()
453 cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); in run()
456 if builder.config.llvm_clang { in run()
457 let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin"); in run()
458 let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION); in run()
459 if !builder.config.dry_run() && !clang_tblgen.exists() { in run()
466 let llvm_version_suffix = if let Some(ref suffix) = builder.config.llvm_version_suffix { in run()
467 // Allow version-suffix="" to not define a version suffix at all. in run()
469 } else if builder.config.channel == "dev" { in run()
470 // Changes to a version suffix require a complete rebuild of the LLVM. in run()
473 Some("-rust-dev".to_string()) in run()
475 Some(format!("-rust-{}-{}", builder.version, builder.config.channel)) in run()
484 for (key, val) in &builder.config.llvm_build_config { in run()
488 if builder.config.dry_run() { in run()
494 // When building LLVM with LLVM_LINK_LLVM_DYLIB for macOS, an unversioned in run()
495 // libLLVM.dylib will be built. However, llvm-config will still look in run()
496 // for a versioned path like libLLVM-14.dylib. Manually create a symbolic in run()
497 // link to make llvm-config happy. in run()
498 if builder.llvm_link_shared() && target.contains("apple-darwin") { in run()
500 let version = output(cmd.arg("--version")); in run()
503 Some(s) => format!("libLLVM-{}{}.dylib", major, s), in run()
504 None => format!("libLLVM-{}.dylib", major), in run()
520 if builder.config.dry_run() { in check_llvm_version()
525 let version = output(cmd.arg("--version")); in check_llvm_version()
532 panic!("\n\nbad LLVM version: {}, need >=14.0\n\n", version) in check_llvm_version()
538 cfg: &mut cmake::Config, in configure_cmake() argument
543 // Do not print installation messages for up-to-date files. in configure_cmake()
544 // LLVM and LLD builds can produce a lot of those and hit CI limits on log size. in configure_cmake()
548 // LLVM will install itself. LLVM must always be installed in our in configure_cmake()
555 cfg.target(&target.triple).host(&builder.config.build.triple); in configure_cmake()
557 if target != builder.config.build { in configure_cmake()
573 // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in in configure_cmake()
576 // Since, the LLVM itself makes rather limited use of version checks in in configure_cmake()
590 cfg.define("CMAKE_OSX_ARCHITECTURES", target.triple.split('-').next().unwrap()); in configure_cmake()
610 let (cc, cxx) = match builder.config.llvm_clang_cl { in configure_cmake()
616 if target.contains("msvc") && builder.ninja() && builder.config.ccache.is_some() { in configure_cmake()
618 wrap_cc.set_file_name("sccache-plus-cl.exe"); in configure_cmake()
622 cfg.env("SCCACHE_PATH", builder.config.ccache.as_ref().unwrap()) in configure_cmake()
627 // Building LLVM on MSVC can be a little ludicrous at times. We're so far in configure_cmake()
631 // * Build LLVM on MSVC in configure_cmake()
632 // * Build LLVM with `clang-cl` instead of `cl.exe` in configure_cmake()
634 // * Build for 32-bit as well in configure_cmake()
638 // we use but for `clang-cl` there's only one which internally in configure_cmake()
642 // use `clang-cl.exe` it's always diagnosed as a 64-bit compiler which in configure_cmake()
644 // 32-bit libraries. in configure_cmake()
648 // correctly diagnose it's doing a 32-bit compilation and LLVM will in configure_cmake()
650 if builder.config.llvm_clang_cl.is_some() && target.contains("i686") { in configure_cmake()
651 cfg.env("SCCACHE_EXTRA_ARGS", "-m32"); in configure_cmake()
657 if let Some(ref ccache) = builder.config.ccache { in configure_cmake()
667 cfg.build_arg("-j").build_arg(builder.jobs().to_string()); in configure_cmake()
668 let mut cflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::C).join(" ").into(); in configure_cmake()
669 if let Some(ref s) = builder.config.llvm_cflags { in configure_cmake()
673 …// Some compiler features used by LLVM (such as thread locals) will not work on a min version belo… in configure_cmake()
674 if target.contains("apple-ios") { in configure_cmake()
675 if target.contains("86-") { in configure_cmake()
676 cflags.push(" -miphonesimulator-version-min=10.0"); in configure_cmake()
678 cflags.push(" -miphoneos-version-min=10.0"); in configure_cmake()
681 if builder.config.llvm_clang_cl.is_some() { in configure_cmake()
682 if target.contains("armv7-unknown-linux-ohos") { in configure_cmake()
683 cflags.push(&format!(" --target={}", "arm-linux-gnueabi")); in configure_cmake()
685 cflags.push(&format!(" --target={}", target)); in configure_cmake()
692 let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into(); in configure_cmake()
693 if let Some(ref s) = builder.config.llvm_cxxflags { in configure_cmake()
697 if builder.config.llvm_clang_cl.is_some() { in configure_cmake()
698 if target.contains("armv7-unknown-linux-ohos") { in configure_cmake()
699 cxxflags.push(&format!(" --target={}", "arm-linux-gnueabi")); in configure_cmake()
701 cxxflags.push(&format!(" --target={}", target)); in configure_cmake()
710 // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it in configure_cmake()
711 // tries to resolve this path in the LLVM build directory. in configure_cmake()
718 // LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it in configure_cmake()
719 // tries to resolve this path in the LLVM build directory. in configure_cmake()
724 if let Some(ref flags) = builder.config.llvm_ldflags { in configure_cmake()
728 if let Some(flags) = get_var("LDFLAGS", &builder.config.build.triple, &target.triple) { in configure_cmake()
732 // For distribution we want the LLVM tools to be *statically* linked to libstdc++. in configure_cmake()
734 if builder.config.llvm_static_stdcpp { in configure_cmake()
737 ldflags.push_all("-static-libstdc++"); in configure_cmake()
739 ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++"); in configure_cmake()
753 fn configure_llvm(builder: &Builder<'_>, target: TargetSelection, cfg: &mut cmake::Config) {
754 // ThinLTO is only available when building with LLVM, enabling LLD is required.
756 if builder.config.llvm_thin_lto {
763 if let Some(ref linker) = builder.config.llvm_use_linker {
767 if builder.config.llvm_allow_old_toolchain {
772 …ted from https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/l…
773 fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
775 let target_u = target.replace("-", "_");
791 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
792 run.path("src/llvm-project/lld")
800 fn run(self, builder: &Builder<'_>) -> PathBuf {
801 if builder.config.dry_run() {
802 return PathBuf::from("lld-out-dir-test-gen");
806 let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target });
808 // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path
809 // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin`
811 // `llvm-config`: if so, we can use it instead of building LLVM/LLD from source.
816 // The following steps copying `lld` as `rust-lld` to the sysroot, expect it in the
823 let done_stamp = out_dir.join("lld-finished-building");
832 let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
836 // when doing PGO on CI, cmake or clang-cl don't automatically link clang's
838 // linking errors, much like LLVM's cmake setup does in that situation.
839 if builder.config.llvm_profile_generate && target.contains("msvc") {
840 if let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref() {
848 // LLD is built as an LLVM tool, but is distributed outside of the `llvm-tools` component,
849 // which impacts where it expects to find LLVM's shared library. This causes #80703.
851 // LLD is distributed at "$root/lib/rustlib/$host/bin/rust-lld", but the `libLLVM-*.so` it
853 // lib path for LLVM tools, not the one for rust binaries.
855 // (The `llvm-tools` component copies the .so there for the other tools, and with that
856 // component installed, one can successfully invoke `rust-lld` directly without rustup's
859 if builder.config.rpath_enabled(target)
861 && builder.config.llvm_link_shared()
864 // So we inform LLD where it can find LLVM's libraries by adding an rpath entry to the
870 ldflags.push_all("-Wl,-rpath,'$ORIGIN/../../../'");
876 // Re-use the same flags as llvm to control the level of debug information
878 let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) {
889 if target != builder.config.build {
890 // Use the host llvm-tblgen binary.
893 llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
912 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
921 fn run(self, builder: &Builder<'_>) -> Self::Output {
922 let compiler_rt_dir = builder.src.join("src/llvm-project/compiler-rt");
928 let runtimes = supported_sanitizers(&out_dir, self.target, &builder.config.channel);
933 let LlvmResult { llvm_config, .. } = builder.ensure(Llvm { target: builder.config.build });
934 if builder.config.dry_run() {
938 let stamp = out_dir.join("sanitizers-finished-building");
955 let mut cfg = cmake::Config::new(&compiler_rt_dir);
957 if self.target.triple == "armv7-unknown-linux-ohos" {
958 cfg.define("CMAKE_C_COMPILER_TARGET", "arm-linux-gnueabi");
975 let use_compiler_launcher = !self.target.contains("apple-darwin");
977 if self.target.contains("apple") { &["-fembed-bitcode=off"] } else { &[] };
1015 ) -> Vec<SanitizerRuntime> {
1016 let darwin_libs = |os: &str, components: &[&str]| -> Vec<SanitizerRuntime> {
1023 name: format!("librustc-{}_rt.{}.dylib", channel, c),
1028 let common_libs = |os: &str, arch: &str, components: &[&str]| -> Vec<SanitizerRuntime> {
1032 cmake_target: format!("clang_rt.{}-{}", c, arch),
1033 path: out_dir.join(&format!("build/lib/{}/libclang_rt.{}-{}.a", os, c, arch)),
1034 name: format!("librustc-{}_rt.{}.a", channel, c),
1040 "aarch64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
1041 "aarch64-apple-ios" => darwin_libs("ios", &["asan", "tsan"]),
1042 "aarch64-apple-ios-sim" => darwin_libs("iossim", &["asan", "tsan"]),
1043 "aarch64-unknown-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]),
1044 "aarch64-unknown-linux-gnu" => {
1047 "aarch64-unknown-linux-ohos" => {
1050 "armv7-unknown-linux-ohos" => {
1053 "x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
1054 "x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
1055 "x86_64-apple-ios" => darwin_libs("iossim", &["asan", "tsan"]),
1056 "x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),
1057 "x86_64-unknown-netbsd" => {
1060 "x86_64-unknown-illumos" => common_libs("illumos", "x86_64", &["asan"]),
1061 "x86_64-pc-solaris" => common_libs("solaris", "x86_64", &["asan"]),
1062 "x86_64-unknown-linux-gnu" => {
1065 "x86_64-unknown-linux-musl" => {
1068 "x86_64-unknown-linux-ohos" => {
1071 "s390x-unknown-linux-gnu" => {
1074 "s390x-unknown-linux-musl" => {
1087 fn new(path: PathBuf, hash: Option<&str>) -> Self {
1091 fn is_done(&self) -> bool {
1101 fn remove(&self) -> io::Result<()> {
1114 fn write(&self) -> io::Result<()> {
1127 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1128 run.path("src/llvm-project/compiler-rt/lib/crt")
1136 fn run(self, builder: &Builder<'_>) -> Self::Output {
1137 builder.update_submodule(&Path::new("src/llvm-project"));
1141 if builder.config.dry_run() {
1145 let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtbegin.c");
1146 let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtend.c");
1165 .host(&builder.config.build.triple)
1172 // Those flags are defined in src/llvm-project/compiler-rt/lib/crt/CMakeLists.txt
1175 cfg.flag("-std=c11")
1195 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1196 run.path("src/llvm-project/libunwind")
1204 fn run(self, builder: &Builder<'_>) -> Self::Output {
1205 builder.update_submodule(&Path::new("src/llvm-project"));
1207 if builder.config.dry_run() {
1212 let root = builder.src.join("src/llvm-project/libunwind");
1226 cpp_cfg.flag("-nostdinc++");
1227 cpp_cfg.flag("-fno-exceptions");
1228 cpp_cfg.flag("-fno-rtti");
1229 cpp_cfg.flag_if_supported("-fvisibility-global-new-delete-hidden");
1236 cfg.host(&builder.config.build.triple);
1241 cfg.flag("-fstrict-aliasing");
1242 cfg.flag("-funwind-tables");
1243 cfg.flag("-fvisibility=hidden");
1249 if self.target.contains("x86_64-fortanix-unknown-sgx") {
1251 cfg.flag("-fno-stack-protector");
1252 cfg.flag("-ffreestanding");
1253 cfg.flag("-fexceptions");
1256 cfg.flag("-U_FORTIFY_SOURCE");
1283 cc_cfg.flag("-std=c99");
1286 cpp_cfg.flag("-std=c++11");
1289 if self.target.contains("x86_64-fortanix-unknown-sgx") || self.target.contains("musl") {
1300 "Unwind-sjlj.c",
1301 "UnwindLevel1-gcc-ext.c",
1307 let cpp_sources = vec!["Unwind-EHABI.cpp", "Unwind-seh.cpp", "libunwind.cpp"];
1310 if self.target.contains("x86_64-fortanix-unknown-sgx") {
1322 cpp_cfg.compile("unwind-cpp");
1324 // FIXME: https://github.com/alexcrichton/cc-rs/issues/545#issuecomment-679242845
1329 // file name starts with "Unwind-EHABI", "Unwind-seh" or "libunwind"
1330 let file_name = file.file_name().unwrap().to_str().expect("UTF-8 file name");
1331 if cpp_sources.iter().any(|f| file_name.starts_with(&f[..f.len() - 4])) {