@@ -1781,6 +1781,19 @@ impl Build {
1781
1781
}
1782
1782
}
1783
1783
ToolFamily :: Gnu => {
1784
+ if self . static_flag . is_none ( )
1785
+ && self
1786
+ . getenv ( "CARGO_CFG_TARGET_FEATURE" )
1787
+ . map ( |feature| feature. contains ( "crt-static" ) )
1788
+ . unwrap_or ( false )
1789
+ {
1790
+ cmd. args . push ( "-static" . into ( ) ) ;
1791
+ } ;
1792
+
1793
+ if target. contains ( "-kmc-solid_" ) {
1794
+ cmd. args . push ( "-finput-charset=utf-8" . into ( ) ) ;
1795
+ }
1796
+
1784
1797
if target. contains ( "i686" ) || target. contains ( "i586" ) {
1785
1798
cmd. args . push ( "-m32" . into ( ) ) ;
1786
1799
} else if target == "x86_64-unknown-linux-gnux32" {
@@ -1797,130 +1810,32 @@ impl Build {
1797
1810
}
1798
1811
}
1799
1812
1800
- if target. contains ( "-kmc-solid_" ) {
1801
- cmd. args . push ( "-finput-charset=utf-8" . into ( ) ) ;
1802
- }
1803
-
1804
- if self . static_flag . is_none ( ) {
1805
- let features = self
1806
- . getenv ( "CARGO_CFG_TARGET_FEATURE" )
1807
- . unwrap_or ( String :: new ( ) ) ;
1808
- if features. contains ( "crt-static" ) {
1809
- cmd. args . push ( "-static" . into ( ) ) ;
1810
- }
1811
- }
1812
-
1813
- // armv7 targets get to use armv7 instructions
1814
- if ( target. starts_with ( "armv7" ) || target. starts_with ( "thumbv7" ) )
1815
- && ( target. contains ( "-linux-" ) || target. contains ( "-kmc-solid_" ) )
1816
- {
1817
- cmd. args . push ( "-march=armv7-a" . into ( ) ) ;
1818
-
1819
- if target. ends_with ( "eabihf" ) {
1820
- // lowest common denominator FPU
1821
- cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
1822
- }
1823
- }
1824
-
1825
- // (x86 Android doesn't say "eabi")
1826
- if target. contains ( "-androideabi" ) && target. contains ( "v7" ) {
1827
- // -march=armv7-a handled above
1828
- cmd. args . push ( "-mthumb" . into ( ) ) ;
1829
- if !target. contains ( "neon" ) {
1830
- // On android we can guarantee some extra float instructions
1831
- // (specified in the android spec online)
1832
- // NEON guarantees even more; see below.
1833
- cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
1834
- }
1835
- cmd. args . push ( "-mfloat-abi=softfp" . into ( ) ) ;
1836
- }
1837
-
1838
- if target. contains ( "neon" ) {
1839
- cmd. args . push ( "-mfpu=neon-vfpv4" . into ( ) ) ;
1840
- }
1841
-
1842
1813
if target. starts_with ( "armv4t-unknown-linux-" ) {
1843
1814
cmd. args . push ( "-march=armv4t" . into ( ) ) ;
1844
1815
cmd. args . push ( "-marm" . into ( ) ) ;
1845
1816
cmd. args . push ( "-mfloat-abi=soft" . into ( ) ) ;
1846
- }
1847
-
1848
- if target. starts_with ( "armv5te-unknown-linux-" ) {
1817
+ } else if target. starts_with ( "armv5te-unknown-linux-" ) {
1849
1818
cmd. args . push ( "-march=armv5te" . into ( ) ) ;
1850
1819
cmd. args . push ( "-marm" . into ( ) ) ;
1851
1820
cmd. args . push ( "-mfloat-abi=soft" . into ( ) ) ;
1852
1821
}
1853
-
1854
1822
// For us arm == armv6 by default
1855
- if target. starts_with ( "arm-unknown-linux-" ) {
1823
+ else if target. starts_with ( "arm-unknown-linux-" ) {
1856
1824
cmd. args . push ( "-march=armv6" . into ( ) ) ;
1857
1825
cmd. args . push ( "-marm" . into ( ) ) ;
1858
1826
if target. ends_with ( "hf" ) {
1859
1827
cmd. args . push ( "-mfpu=vfp" . into ( ) ) ;
1860
1828
} else {
1861
1829
cmd. args . push ( "-mfloat-abi=soft" . into ( ) ) ;
1862
1830
}
1863
- }
1864
-
1865
- // We can guarantee some settings for FRC
1866
- if target. starts_with ( "arm-frc-" ) {
1831
+ } else if target. starts_with ( "armv7a" ) {
1867
1832
cmd. args . push ( "-march=armv7-a" . into ( ) ) ;
1868
- cmd. args . push ( "-mcpu=cortex-a9" . into ( ) ) ;
1869
- cmd. args . push ( "-mfpu=vfpv3" . into ( ) ) ;
1870
- cmd. args . push ( "-mfloat-abi=softfp" . into ( ) ) ;
1871
- cmd. args . push ( "-marm" . into ( ) ) ;
1872
- }
1873
-
1874
- // Turn codegen down on i586 to avoid some instructions.
1875
- if target. starts_with ( "i586-unknown-linux-" ) {
1876
- cmd. args . push ( "-march=pentium" . into ( ) ) ;
1877
- }
1878
-
1879
- // Set codegen level for i686 correctly
1880
- if target. starts_with ( "i686-unknown-linux-" ) {
1881
- cmd. args . push ( "-march=i686" . into ( ) ) ;
1882
- }
1883
-
1884
- // Looks like `musl-gcc` makes it hard for `-m32` to make its way
1885
- // all the way to the linker, so we need to actually instruct the
1886
- // linker that we're generating 32-bit executables as well. This'll
1887
- // typically only be used for build scripts which transitively use
1888
- // these flags that try to compile executables.
1889
- if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" {
1890
- cmd. args . push ( "-Wl,-melf_i386" . into ( ) ) ;
1891
- }
1892
-
1893
- if target. starts_with ( "thumb" ) {
1894
- cmd. args . push ( "-mthumb" . into ( ) ) ;
1895
-
1896
- if target. ends_with ( "eabihf" ) {
1897
- cmd. args . push ( "-mfloat-abi=hard" . into ( ) )
1898
- }
1899
- }
1900
- if target. starts_with ( "thumbv6m" ) {
1901
- cmd. args . push ( "-march=armv6s-m" . into ( ) ) ;
1902
- }
1903
- if target. starts_with ( "thumbv7em" ) {
1904
- cmd. args . push ( "-march=armv7e-m" . into ( ) ) ;
1905
1833
1906
1834
if target. ends_with ( "eabihf" ) {
1907
- cmd. args . push ( "-mfpu=fpv4-sp-d16" . into ( ) )
1908
- }
1909
- }
1910
- if target. starts_with ( "thumbv7m" ) {
1911
- cmd. args . push ( "-march=armv7-m" . into ( ) ) ;
1912
- }
1913
- if target. starts_with ( "thumbv8m.base" ) {
1914
- cmd. args . push ( "-march=armv8-m.base" . into ( ) ) ;
1915
- }
1916
- if target. starts_with ( "thumbv8m.main" ) {
1917
- cmd. args . push ( "-march=armv8-m.main" . into ( ) ) ;
1918
-
1919
- if target. ends_with ( "eabihf" ) {
1920
- cmd. args . push ( "-mfpu=fpv5-sp-d16" . into ( ) )
1835
+ // lowest common denominator FPU
1836
+ cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
1921
1837
}
1922
- }
1923
- if target. starts_with ( "armebv7r" ) | target. starts_with ( "armv7r" ) {
1838
+ } else if target. starts_with ( "armebv7r" ) || target. starts_with ( "armv7r" ) {
1924
1839
if target. starts_with ( "armeb" ) {
1925
1840
cmd. args . push ( "-mbig-endian" . into ( ) ) ;
1926
1841
} else {
@@ -1929,7 +1844,6 @@ impl Build {
1929
1844
1930
1845
// ARM mode
1931
1846
cmd. args . push ( "-marm" . into ( ) ) ;
1932
-
1933
1847
// R Profile
1934
1848
cmd. args . push ( "-march=armv7-r" . into ( ) ) ;
1935
1849
@@ -1945,15 +1859,50 @@ impl Build {
1945
1859
cmd. args . push ( "-mfloat-abi=soft" . into ( ) ) ;
1946
1860
}
1947
1861
}
1948
- if target. starts_with ( "armv7a" ) {
1862
+ // We can guarantee some settings for FRC
1863
+ else if target. starts_with ( "arm-frc-" ) {
1949
1864
cmd. args . push ( "-march=armv7-a" . into ( ) ) ;
1865
+ cmd. args . push ( "-mcpu=cortex-a9" . into ( ) ) ;
1866
+ cmd. args . push ( "-mfpu=vfpv3" . into ( ) ) ;
1867
+ cmd. args . push ( "-mfloat-abi=softfp" . into ( ) ) ;
1868
+ cmd. args . push ( "-marm" . into ( ) ) ;
1869
+ }
1870
+ // Turn codegen down on i586 to avoid some instructions.
1871
+ else if target. starts_with ( "i586-unknown-linux-" ) {
1872
+ cmd. args . push ( "-march=pentium" . into ( ) ) ;
1873
+ }
1874
+ // Set codegen level for i686 correctly
1875
+ else if target. starts_with ( "i686-unknown-linux-" ) {
1876
+ cmd. args . push ( "-march=i686" . into ( ) ) ;
1877
+ }
1878
+ // Shared branch for all thumb targets
1879
+ else if target. starts_with ( "thumb" ) {
1880
+ cmd. args . push ( "-mthumb" . into ( ) ) ;
1950
1881
1951
1882
if target. ends_with ( "eabihf" ) {
1952
- // lowest common denominator FPU
1953
- cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
1883
+ cmd. args . push ( "-mfloat-abi=hard" . into ( ) )
1954
1884
}
1955
- }
1956
- if target. starts_with ( "riscv32" ) || target. starts_with ( "riscv64" ) {
1885
+
1886
+ if target. starts_with ( "thumbv6m" ) {
1887
+ cmd. args . push ( "-march=armv6s-m" . into ( ) ) ;
1888
+ } else if target. starts_with ( "thumbv7em" ) {
1889
+ cmd. args . push ( "-march=armv7e-m" . into ( ) ) ;
1890
+
1891
+ if target. ends_with ( "eabihf" ) {
1892
+ cmd. args . push ( "-mfpu=fpv4-sp-d16" . into ( ) )
1893
+ }
1894
+ } else if target. starts_with ( "thumbv7m" ) {
1895
+ cmd. args . push ( "-march=armv7-m" . into ( ) ) ;
1896
+ } else if target. starts_with ( "thumbv8m.base" ) {
1897
+ cmd. args . push ( "-march=armv8-m.base" . into ( ) ) ;
1898
+ } else if target. starts_with ( "thumbv8m.main" ) {
1899
+ cmd. args . push ( "-march=armv8-m.main" . into ( ) ) ;
1900
+
1901
+ if target. ends_with ( "eabihf" ) {
1902
+ cmd. args . push ( "-mfpu=fpv5-sp-d16" . into ( ) )
1903
+ }
1904
+ }
1905
+ } else if target. starts_with ( "riscv32" ) || target. starts_with ( "riscv64" ) {
1957
1906
// get the 32i/32imac/32imc/64gc/64imac/... part
1958
1907
let mut parts = target. split ( '-' ) ;
1959
1908
if let Some ( arch) = parts. next ( ) {
@@ -1980,6 +1929,32 @@ impl Build {
1980
1929
cmd. args . push ( "-mcmodel=medany" . into ( ) ) ;
1981
1930
}
1982
1931
}
1932
+
1933
+ // (x86 Android doesn't say "eabi")
1934
+ if target. contains ( "-androideabi" ) && target. contains ( "v7" ) {
1935
+ // -march=armv7-a handled above
1936
+ cmd. args . push ( "-mthumb" . into ( ) ) ;
1937
+ if !target. contains ( "neon" ) {
1938
+ // On android we can guarantee some extra float instructions
1939
+ // (specified in the android spec online)
1940
+ // NEON guarantees even more; see below.
1941
+ cmd. args . push ( "-mfpu=vfpv3-d16" . into ( ) ) ;
1942
+ }
1943
+ cmd. args . push ( "-mfloat-abi=softfp" . into ( ) ) ;
1944
+ }
1945
+
1946
+ // Looks like `musl-gcc` makes it hard for `-m32` to make its way
1947
+ // all the way to the linker, so we need to actually instruct the
1948
+ // linker that we're generating 32-bit executables as well. This'll
1949
+ // typically only be used for build scripts which transitively use
1950
+ // these flags that try to compile executables.
1951
+ if target == "i686-unknown-linux-musl" || target == "i586-unknown-linux-musl" {
1952
+ cmd. args . push ( "-Wl,-melf_i386" . into ( ) ) ;
1953
+ }
1954
+
1955
+ if target. contains ( "neon" ) {
1956
+ cmd. args . push ( "-mfpu=neon-vfpv4" . into ( ) ) ;
1957
+ }
1983
1958
}
1984
1959
}
1985
1960
@@ -1990,6 +1965,7 @@ impl Build {
1990
1965
if self . static_flag . unwrap_or ( false ) {
1991
1966
cmd. args . push ( "-static" . into ( ) ) ;
1992
1967
}
1968
+
1993
1969
if self . shared_flag . unwrap_or ( false ) {
1994
1970
cmd. args . push ( "-shared" . into ( ) ) ;
1995
1971
}
0 commit comments