Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ function false_true() {
CROSS_COMPILE_HOSTS=($CROSS_COMPILE_HOSTS)
for t in "${CROSS_COMPILE_HOSTS[@]}"; do
case ${t} in
macosx* | iphone* | appletv* | watch* | linux-armv5 | linux-armv6 | linux-armv7 | android-* | openbsd-* | linux-static-* )
macosx* | iphone* | appletv* | watch* | android-* | openbsd-* | linux-* | linux-static-* )
;;
*)
echo "Unknown host to cross-compile for: ${t}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ def get_linux_target_components(self, arch):
def get_linux_sysroot(self, platform, arch):
if not self.is_cross_compile_target('{}-{}'.format(platform, arch)):
return None

# If the deps path was passed, use it instead
if self.args.cross_compile_deps_path:
return self.args.cross_compile_deps_path

sysroot_arch, _, abi = self.get_linux_target_components(arch)
# $ARCH-$PLATFORM-$ABI
# E.x.: aarch64-linux-gnu
Expand Down Expand Up @@ -479,6 +484,11 @@ def common_cross_c_flags(self, platform, arch, include_arch=False):
if self.is_release():
cross_flags.append('-fno-stack-protector')

# Use lld when cross-compiling to a Linux arch
if (self.is_cross_compile_target("{}-{}".format(platform, arch))
and platform == 'linux'):
cross_flags.append('-w -fuse-ld=lld')

return self.common_c_flags + cross_flags


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def setUp(self):
clang_compiler_version=None,
clang_user_visible_version=None,
cross_compile_hosts='linux-aarch64',
cross_compile_deps_path='sysroot'
cross_compile_deps_path=None,
build_variant='Release'
)

# Setup shell
Expand All @@ -59,11 +60,38 @@ def tearDown(self):
self.toolchain = None
self.args = None

def test_llvm_get_linux_sysroot(self):
def test_llvm_get_linux_sysroot_default(self):
llvm = LLVM(
args=self.args,
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
expected_arg = '/usr/aarch64-linux-gnu'
self.assertIn(expected_arg, llvm.get_linux_sysroot("linux", "aarch64"))

def test_llvm_get_linux_sysroot_external(self):
self.args = argparse.Namespace(
llvm_targets_to_build='X86;ARM;AArch64',
llvm_assertions='true',
compiler_vendor='none',
clang_compiler_version=None,
clang_user_visible_version=None,
cross_compile_hosts='linux-armv7',
cross_compile_deps_path='sysroot'
)
llvm = LLVM(
args=self.args,
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
expected_arg = 'sysroot'
self.assertIn(expected_arg, llvm.get_linux_sysroot("linux", "armv7"))

def test_llvm_c_flags_includes_lld(self):
llvm = LLVM(
args=self.args,
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
expected_flag = '-w -fuse-ld=lld'
self.assertIn(expected_flag, llvm.llvm_c_flags("linux", "aarch64"))