Index: llvm/utils/gn/build/BUILD.gn =================================================================== --- llvm/utils/gn/build/BUILD.gn +++ llvm/utils/gn/build/BUILD.gn @@ -137,6 +137,14 @@ ldflags += [ "/STACK:10000000" ] } + if (host_os != current_os && !(host_os == "mac" && current_os == "ios")) { + if (current_os == "linux" && current_cpu == "x64") { + cflags += [ "--target=x86_64-linux-gnu" ] + } else { + assert(false, "unimplemented cross config $host_os => $current_os") + } + } + # Warning setup. if (host_os == "win" && !is_clang) { cflags += [ Index: llvm/utils/gn/build/toolchain/BUILD.gn =================================================================== --- llvm/utils/gn/build/toolchain/BUILD.gn +++ llvm/utils/gn/build/toolchain/BUILD.gn @@ -193,7 +193,7 @@ "//:clang($host_toolchain)", "//:lld($host_toolchain)", ] - if (current_os != "ios" && current_os != "mac") { + if (toolchain_args.current_os != "ios" && toolchain_args.current_os != "mac") { ar = "bin/llvm-ar" deps += [ "//:llvm-ar($host_toolchain)" ] } @@ -207,6 +207,14 @@ } } +stage2_unix_toolchain("stage2_unix_linux") { + toolchain_args = { + current_os = "linux" + current_cpu = host_cpu + sysroot = "//sysroot-linux" + } +} + if (android_ndk_path != "") { stage2_unix_toolchain("stage2_android_aarch64") { toolchain_args = { Index: llvm/utils/gn/secondary/compiler-rt/BUILD.gn =================================================================== --- llvm/utils/gn/secondary/compiler-rt/BUILD.gn +++ llvm/utils/gn/secondary/compiler-rt/BUILD.gn @@ -10,6 +10,9 @@ } else { supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] } +if (current_os == "mac") { + supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix_linux" ] +} if (android_ndk_path != "") { supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",