@@ -1978,8 +1978,8 @@ impl Build {
19781978 // Disambiguate mingw and msvc on Windows. Problem is that
19791979 // depending on the origin clang can default to a mismatchig
19801980 // run-time.
1981- // FIXME: Convert rustc target to Clang target.
1982- cmd. push_cc_arg ( format ! ( "--target={raw_target }" ) . into ( ) ) ;
1981+ let llvm_target = target. versioned_llvm_target ( None ) ;
1982+ cmd. push_cc_arg ( format ! ( "--target={llvm_target }" ) . into ( ) ) ;
19831983 }
19841984
19851985 if cmd. is_like_clang ( ) && target. os == "android" {
@@ -2065,77 +2065,7 @@ impl Build {
20652065 || ( target. os == "android"
20662066 && android_clang_compiler_uses_target_arg_internally ( & cmd. path ) ) )
20672067 {
2068- if target. os == "macos" {
2069- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2070- cmd. args
2071- . push ( format ! ( "--target={}-apple-darwin" , arch) . into ( ) ) ;
2072- } else if target. abi == "macabi" {
2073- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2074- cmd. args
2075- . push ( format ! ( "--target={}-apple-ios-macabi" , arch) . into ( ) ) ;
2076- } else if target. os == "ios" && target. abi == "sim" {
2077- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2078- let deployment_target = self . apple_deployment_target ( target) ;
2079- cmd. args . push (
2080- format ! ( "--target={}-apple-ios{}-simulator" , arch, deployment_target)
2081- . into ( ) ,
2082- ) ;
2083- } else if target. os == "watchos" && target. abi == "sim" {
2084- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2085- let deployment_target = self . apple_deployment_target ( target) ;
2086- cmd. args . push (
2087- format ! (
2088- "--target={}-apple-watchos{}-simulator" ,
2089- arch, deployment_target
2090- )
2091- . into ( ) ,
2092- ) ;
2093- } else if target. os == "tvos" && target. abi == "sim" {
2094- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2095- let deployment_target = self . apple_deployment_target ( target) ;
2096- cmd. args . push (
2097- format ! (
2098- "--target={}-apple-tvos{}-simulator" ,
2099- arch, deployment_target
2100- )
2101- . into ( ) ,
2102- ) ;
2103- } else if target. os == "tvos" {
2104- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2105- let deployment_target = self . apple_deployment_target ( target) ;
2106- cmd. args . push (
2107- format ! ( "--target={}-apple-tvos{}" , arch, deployment_target) . into ( ) ,
2108- ) ;
2109- } else if target. os == "visionos" && target. abi == "sim" {
2110- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2111- let deployment_target = self . apple_deployment_target ( target) ;
2112- cmd. args . push (
2113- format ! (
2114- "--target={}-apple-xros{}-simulator" ,
2115- arch, deployment_target
2116- )
2117- . into ( ) ,
2118- ) ;
2119- } else if target. os == "visionos" {
2120- let arch = map_darwin_target_from_rust_to_compiler_architecture ( target) ;
2121- let deployment_target = self . apple_deployment_target ( target) ;
2122- cmd. args . push (
2123- format ! ( "--target={}-apple-xros{}" , arch, deployment_target) . into ( ) ,
2124- ) ;
2125- } else if target. arch == "riscv32" || target. arch == "riscv64" {
2126- // FIXME: Convert rustc target to Clang target
2127- let ( _, rest) = raw_target. split_once ( '-' ) . unwrap ( ) ;
2128- cmd. args
2129- . push ( format ! ( "--target={}-{}" , & target. arch, rest) . into ( ) ) ;
2130- } else if target. os == "uefi" {
2131- if target. arch == "x86_64" {
2132- cmd. args . push ( "--target=x86_64-unknown-windows-gnu" . into ( ) ) ;
2133- } else if target. arch == "x86" {
2134- cmd. args . push ( "--target=i686-unknown-windows-gnu" . into ( ) )
2135- } else if target. arch == "aarch64" {
2136- cmd. args . push ( "--target=aarch64-unknown-windows-gnu" . into ( ) )
2137- }
2138- } else if target. os == "freebsd" {
2068+ if target. os == "freebsd" {
21392069 // FreeBSD only supports C++11 and above when compiling against libc++
21402070 // (available from FreeBSD 10 onwards). Under FreeBSD, clang uses libc++ by
21412071 // default on FreeBSD 10 and newer unless `--target` is manually passed to
@@ -2157,18 +2087,21 @@ impl Build {
21572087 if self . cpp && self . cpp_set_stdlib . is_none ( ) {
21582088 cmd. push_cc_arg ( "-stdlib=libc++" . into ( ) ) ;
21592089 }
2090+ }
21602091
2161- // FIXME: Convert rustc target to Clang target.
2162- cmd. push_cc_arg ( format ! ( "--target={}" , raw_target) . into ( ) ) ;
2163- } else if target. os == "windows" {
2164- cmd. args . push (
2165- format ! ( "--target={}-pc-windows-{}" , target. full_arch, target. env)
2166- . into ( ) ,
2167- )
2092+ // Add version information to the target.
2093+ // FIXME(madsmtm): Enable this on macOS and Mac Catalyst as well.
2094+ let llvm_target = if target. vendor == "apple"
2095+ && target. os != "macos"
2096+ && target. abi != "macabi"
2097+ {
2098+ let deployment_target = self . apple_deployment_target ( target) ;
2099+ target. versioned_llvm_target ( Some ( & deployment_target) )
21682100 } else {
2169- // FIXME: Convert rustc target to Clang target.
2170- cmd. push_cc_arg ( format ! ( "--target={}" , raw_target) . into ( ) ) ;
2171- }
2101+ target. versioned_llvm_target ( None )
2102+ } ;
2103+
2104+ cmd. args . push ( format ! ( "--target={llvm_target}" ) . into ( ) ) ;
21722105 }
21732106 }
21742107 ToolFamily :: Msvc { clang_cl } => {
@@ -2184,8 +2117,8 @@ impl Build {
21842117 cmd. push_cc_arg ( "-m32" . into ( ) ) ;
21852118 cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
21862119 } else {
2187- // FIXME: Convert rustc target to Clang target.
2188- cmd. push_cc_arg ( format ! ( "--target={}" , raw_target ) . into ( ) ) ;
2120+ let llvm_target = target. versioned_llvm_target ( None ) ;
2121+ cmd. push_cc_arg ( format ! ( "--target={llvm_target}" ) . into ( ) ) ;
21892122 }
21902123 } else if target. full_arch == "i586" {
21912124 cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
0 commit comments