File tree Expand file tree Collapse file tree 4 files changed +9
-1
lines changed Expand file tree Collapse file tree 4 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use target::Target;
1313pub fn target ( ) -> Target {
1414 let mut base = super :: linux_base:: opts ( ) ;
1515 base. pre_link_args . push ( "-Wl,--allow-multiple-definition" . to_string ( ) ) ;
16+ base. is_like_android = true ;
1617 base. position_independent_executables = true ;
1718 Target {
1819 data_layout : "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ pub fn target() -> Target {
1616 // Many of the symbols defined in compiler-rt are also defined in libgcc. Android
1717 // linker doesn't like that by default.
1818 base. pre_link_args . push ( "-Wl,--allow-multiple-definition" . to_string ( ) ) ;
19+ base. is_like_android = true ;
1920 // FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore.
2021 base. position_independent_executables = false ;
2122
Original file line number Diff line number Diff line change @@ -158,6 +158,9 @@ pub struct TargetOptions {
158158 /// only realy used for figuring out how to find libraries, since Windows uses its own
159159 /// library naming convention. Defaults to false.
160160 pub is_like_windows : bool ,
161+ /// Whether the target toolchain is like Android's. Only useful for compiling against Android.
162+ /// Defaults to false.
163+ pub is_like_android : bool ,
161164 /// Whether the linker support GNU-like arguments such as -O. Defaults to false.
162165 pub linker_is_gnu : bool ,
163166 /// Whether the linker support rpaths or not. Defaults to false.
@@ -197,6 +200,7 @@ impl Default for TargetOptions {
197200 staticlib_suffix : ".a" . to_string ( ) ,
198201 is_like_osx : false ,
199202 is_like_windows : false ,
203+ is_like_android : false ,
200204 linker_is_gnu : false ,
201205 has_rpath : false ,
202206 no_compiler_rt : false ,
Original file line number Diff line number Diff line change @@ -736,7 +736,9 @@ pub fn finalize(cx: &CrateContext) {
736736 // instruct LLVM to emit an older version of dwarf, however,
737737 // for OS X to understand. For more info see #11352
738738 // This can be overridden using --llvm-opts -dwarf-version,N.
739- if cx. sess ( ) . target . target . options . is_like_osx {
739+ // Android has the same issue (#22398)
740+ if cx. sess ( ) . target . target . options . is_like_osx ||
741+ cx. sess ( ) . target . target . options . is_like_android {
740742 llvm:: LLVMRustAddModuleFlag ( cx. llmod ( ) ,
741743 "Dwarf Version\0 " . as_ptr ( ) as * const _ ,
742744 2 )
You can’t perform that action at this time.
0 commit comments