diff options
author | Matthew Waters <matthew@centricular.com> | 2023-05-31 11:07:30 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2023-06-04 13:42:51 +1000 |
commit | 976ca291952c026df38a49dcec945ba05b9d04db (patch) | |
tree | 3bd3657c28157cb93e8729117a76bd2473a6f262 /config | |
parent | 56c7792b4c19ad94de0f95e942b637049d8ef5dc (diff) |
config/android: update toolchain for gcc tools removal
Everything is done through clang/++ now.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1191>
Diffstat (limited to 'config')
-rw-r--r-- | config/android.config | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/config/android.config b/config/android.config index b2c586b0..ff14bd42 100644 --- a/config/android.config +++ b/config/android.config @@ -89,20 +89,15 @@ elif target_arch == Architecture.UNIVERSAL: else: raise FatalError(f'Arch {target_arch} not supported') -if platform == Platform.DARWIN: - tc_arch = 'darwin-x86_64' -elif platform == Platform.LINUX: +if platform == Platform.LINUX: tc_arch = 'linux-x86_64' else: raise FatalError(f'Platform {platform} is not supported') llvm_toolchain_path = f'{toolchain_prefix}/toolchains/llvm/prebuilt/{tc_arch}/bin' -gcc_toolchain_root = f'{toolchain_prefix}/toolchains/{tools_dir}-4.9/prebuilt/{tc_arch}' spirv_toolchain_path = f'{toolchain_prefix}/shader-tools/{tc_arch}' -gcc_toolchain_path = os.path.join (gcc_toolchain_root, 'bin') - -isysroot = f'{toolchain_prefix}/sysroot' -sysroot = f'{toolchain_prefix}/platforms/android-{v}/arch-{_android_arch}' +isysroot = f'{toolchain_prefix}/toolchains/llvm/prebuilt/linux-x86_64/sysroot' +sysroot = f'{toolchain_prefix}/toolchains/llvm/prebuilt/linux-x86_64/sysroot' # Default compiler flags env['CFLAGS'] = '' @@ -130,20 +125,20 @@ if target_arch != Architecture.UNIVERSAL and not os.path.exists(lib_dir): # Most of the compiler/linker specific flags are taken from # from android-ndk-r16/build/core/toolchains/$NAME-$VERSION/setup.mk ccache = use_ccache and 'ccache ' or '' -defines = f'-DANDROID -DPIC -D__ANDROID_API__={v} ' +defines = f'-DANDROID -DPIC ' # -fno-integrated-as cause some libraries (e.g. pixman) fail to build with # clang's assembler # -target is being duplicated here and in CC variable to workaround cmake # ignoring arguments in CC while other build systems may ignore CFLAGS for # certain checks. -cflags = f'-target {llvm_triple} --sysroot {sysroot} -gcc-toolchain {gcc_toolchain_root} -isysroot {isysroot} -isystem {incl_dir} -isystem {isysroot}/usr/include -isystem {isysroot}/usr/include/{tools_prefix} -fno-integrated-as -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -Wno-invalid-command-line-argument -Wno-unused-command-line-argument ' +cflags = f'-target {llvm_triple} --sysroot {sysroot} -isysroot {isysroot} -isystem {incl_dir} -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -Wno-invalid-command-line-argument -Wno-unused-command-line-argument ' # http://b.android.com/220159 http://b.android.com/222239 if target_arch == Architecture.X86: if v < 24: cflags += ' -mstackrealign' -ldflags = f'-gcc-toolchain {gcc_toolchain_root} -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--warn-shared-textrel ' +ldflags = f'-fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--warn-shared-textrel ' if target_arch == Architecture.ARMv7: defines += ' -D__ARM_ARCH_7A__ ' @@ -156,45 +151,45 @@ ldflags += ' -L' + lib_dir if not target_arch in [Architecture.ARM64, Architecture.X86_64]: # nocopyreloc causes broken linking on arm64 ldflags += ' -Wl,-z,nocopyreloc ' -if target_arch in [Architecture.X86_64]: - ldflags += f' -L{sysroot}/usr/lib64 ' -else: - ldflags += f' -L{sysroot}/usr/lib ' - -ldvariant = 'gold' -ldflags += f' -fuse-ld={ldvariant} ' # this C++ stl setup is closely tied to the gnustl recipe which sets up the # necessary environment and files for this stl_prefix = os.path.join(toolchain_prefix, 'sources', 'cxx-stl', 'llvm-libc++') stl_libdir = os.path.join(toolchain_prefix, 'libs', _cxx_arch) +ldflags += f' -L{sysroot}/usr/lib/{host}/{v} ' + stl_cxxlinkargs = ['-nostdlib++', '-L' + stl_libdir, '-lc++_shared'] stl_cxxflags = '-nostdlib++ -isystem ' + os.path.join (stl_prefix, 'include') + ' -isystem ' + os.path.join (stl_prefix, '..', 'llvm-libc++abi', 'include') +ldvariant = 'lld' +ldflags += f' -fuse-ld={ldvariant} ' + # Toolchain environment env['CPPFLAGS'] = defines env['CFLAGS'] += f'{cflags} {defines} -Wa,--noexecstack' env['CXXFLAGS'] = stl_cxxflags + ' ' + env['CFLAGS'] + ' -fno-rtti -fno-exceptions ' env['LDFLAGS'] = ldflags + ' -nostdlib++' -def cmd(command): - return f'{tools_prefix}-{command}' +def llvm_cmd(command): + return os.path.join(llvm_toolchain_path, command) # clang requires the full path otherwise it does stupid things and can't # find it's own binary -env['CC']= ccache + os.path.join(llvm_toolchain_path, 'clang') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' -env['CXX']= ccache + os.path.join(llvm_toolchain_path, 'clang++') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' -env['LD']= cmd(f'ld.{ldvariant}') -env['CPP']= os.path.join(llvm_toolchain_path, 'clang') + ' -E' -env['RANLIB']= cmd('ranlib') -env['AR']= cmd('ar') -env['AS']= cmd('as') -env['NM']= cmd('nm') -env['STRIP']= cmd('strip') -env['OBJCOPY']= cmd('objcopy') - -env['PATH'] = f'{toolchain_prefix}:{llvm_toolchain_path}:{gcc_toolchain_path}:{spirv_toolchain_path}:{env["PATH"]}' +env['CC']= ccache + llvm_cmd('clang') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' +env['CC_FOR_BUILD']= ccache + llvm_cmd('clang') +env['CXX']= ccache + llvm_cmd('clang++') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' +# linker should be invoked through the clang/++ frontend +env['LD']= '' +env['CPP']= llvm_cmd('clang') + ' -E' +env['RANLIB']= llvm_cmd('llvm-ranlib') +env['AR']= llvm_cmd('llvm-ar') +env['AS']= llvm_cmd('llvm-as') +env['NM']= llvm_cmd('llvm-nm') +env['STRIP']= llvm_cmd('llvm-strip') +env['OBJCOPY']= llvm_cmd('llvm-objcopy') + +env['PATH'] = f'{llvm_toolchain_path}:{spirv_toolchain_path}:{env["PATH"]}' # For the libc.so dependency in i686-linux-android-as if target_arch == Architecture.X86: extra_lib_path = f'{sysroot}/usr/lib' |