This is an archive of the discontinued LLVM Phabricator instance.

[gn build] Fix Android compiler-rt targets
ClosedPublic

Authored by aeubanks on Nov 10 2021, 12:54 PM.

Details

Summary

If a sysroot was specified, it would take precedence over the Android
NDK sysroot since it would appear after in the command line.

Also only build runtimes for enabled target arches. Many places have
copied this around so create and use supported_android_toolchains.

Diff Detail

Event Timeline

aeubanks created this revision.Nov 10 2021, 12:54 PM
aeubanks requested review of this revision.Nov 10 2021, 12:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 12:54 PM

or maybe the general sysroot flag can be part of the default llvm_code config instead? all the compiler-rt targets opt out of that config

pcc added a subscriber: pcc.Nov 10 2021, 1:15 PM
pcc added inline comments.
llvm/utils/gn/build/BUILD.gn
272

Maybe this should be

} else if (current_os != "ios" && current_os != "mac" && current_os != "android") {

instead? (Random thought: maybe we should change how sysroot works to better support cross compilation -- maybe a different variable for each target OS? -- but not as part of this change, I imagine.)

pcc added a comment.Nov 10 2021, 1:16 PM

I don't think we can use llvm_code for this because we do cross-compile other parts of LLVM for Android (llvm-symbolizer, lldb-server).

aeubanks updated this revision to Diff 386299.Nov 10 2021, 1:22 PM

use pcc's suggestion

pcc added inline comments.Nov 10 2021, 1:28 PM
llvm/utils/gn/secondary/compiler-rt/BUILD.gn
15–23

I think this will need to be refactored a bit because the list of supported Android toolchains has been copied into a few places (grep for stage2_android_aarch64). Maybe create a supported_android_toolchains variable and use it in those places?

aeubanks updated this revision to Diff 386305.Nov 10 2021, 1:45 PM

create supported_android_toolchains

aeubanks edited the summary of this revision. (Show Details)Nov 10 2021, 1:45 PM
aeubanks updated this revision to Diff 386639.Nov 11 2021, 1:17 PM

fix hwasan (only AArch64 is supported)

pcc accepted this revision.Nov 11 2021, 3:19 PM

LGTM

This revision is now accepted and ready to land.Nov 11 2021, 3:19 PM
This revision was landed with ongoing or failed builds.Nov 11 2021, 6:42 PM
This revision was automatically updated to reflect the committed changes.