Unverified Commit c2cc37a0 authored by Ivan Matkov's avatar Ivan Matkov Committed by GitHub

Update GCC version to 10 (#1132)

In 0.9.36, there was a missing symbol that caused
```
libskiko-linux-x64.so: undefined symbol: _ZNSt19_Sp_make_shared_tag5_S_eqERKSt9type_info
```

It's because the build attempts to statically link the C++ standard
library, but:
- Skia's object files reference newer libstdc++ symbols
- GCC 7.3's `libstdc++` doesn't contain these symbols
- The static linking fails to resolve these symbols

GCC was downgraded from 9 to 7 in #1130 during the switch to AL2 to
provide better GLIBC compatibility.
Since AL2
[provides](https://docs.aws.amazon.com/linux/al2/ug/c-cplusplus.html)
only GCC 7.3 by default and GCC 10, installing GCC 9 is problematic
there, so it's bumped to 10

However, GCC 10 introduces outline atomics as default for new ARM chips,
the build might fail due to missing symbols like
```
org_jetbrains_skia_FontMgrWithFallback__1nDefaultWithFallbackFontProvider: error: undefined reference to '__aarch64_ldadd4_relax'
org_jetbrains_skia_FontMgrWithFallback__1nDefaultWithFallbackFontProvider: error: undefined reference to '__aarch64_ldadd4_acq_rel'
```
so, to keep things compatible with the previous GCC version,
`-mno-outline-atomics` option was added to disable this new behavior.
parent 49fea5b9
...@@ -85,6 +85,10 @@ fun SkikoProjectContext.createCompileJvmBindingsTask( ...@@ -85,6 +85,10 @@ fun SkikoProjectContext.createCompileJvmBindingsTask(
OS.Linux -> { OS.Linux -> {
includeHeadersNonRecursive(jdkHome.resolve("include/linux")) includeHeadersNonRecursive(jdkHome.resolve("include/linux"))
includeHeadersNonRecursive(runPkgConfig("dbus-1")) includeHeadersNonRecursive(runPkgConfig("dbus-1"))
val archFlags = if (targetArch == Arch.Arm64) arrayOf(
// Always inline atomics for ARM64 to prevent linking incompatibility issues after updating GCC to 10
"-mno-outline-atomics",
) else arrayOf()
osFlags = arrayOf( osFlags = arrayOf(
*buildType.clangFlags, *buildType.clangFlags,
"-DGL_GLEXT_PROTOTYPES", "-DGL_GLEXT_PROTOTYPES",
...@@ -92,7 +96,8 @@ fun SkikoProjectContext.createCompileJvmBindingsTask( ...@@ -92,7 +96,8 @@ fun SkikoProjectContext.createCompileJvmBindingsTask(
"-fno-rtti", "-fno-rtti",
"-fno-exceptions", "-fno-exceptions",
"-fvisibility=hidden", "-fvisibility=hidden",
"-fvisibility-inlines-hidden" "-fvisibility-inlines-hidden",
*archFlags,
) )
} }
OS.Windows -> { OS.Windows -> {
......
...@@ -127,6 +127,10 @@ fun SkikoProjectContext.compileNativeBridgesTask( ...@@ -127,6 +127,10 @@ fun SkikoProjectContext.compileNativeBridgesTask(
)) ))
} }
OS.Linux -> { OS.Linux -> {
val archFlags = if (arch == Arch.Arm64) arrayOf(
// Always inline atomics for ARM64 to prevent linking incompatibility issues after updating GCC to 10
"-mno-outline-atomics",
) else arrayOf()
val linuxFlags = mutableListOf( val linuxFlags = mutableListOf(
*buildType.clangFlags, *buildType.clangFlags,
"-fPIC", "-fPIC",
...@@ -134,6 +138,7 @@ fun SkikoProjectContext.compileNativeBridgesTask( ...@@ -134,6 +138,7 @@ fun SkikoProjectContext.compileNativeBridgesTask(
"-fno-exceptions", "-fno-exceptions",
"-fvisibility=hidden", "-fvisibility=hidden",
"-fvisibility-inlines-hidden", "-fvisibility-inlines-hidden",
*archFlags,
*skiaPreprocessorFlags(OS.Linux, buildType) *skiaPreprocessorFlags(OS.Linux, buildType)
) )
// Add sysroot for ARM64 cross-compilation // Add sysroot for ARM64 cross-compilation
......
...@@ -6,6 +6,9 @@ RUN apt update -y && \ ...@@ -6,6 +6,9 @@ RUN apt update -y && \
apt install zip unzip git python curl wget xvfb -y && \ apt install zip unzip git python curl wget xvfb -y && \
apt install fontconfig libfontconfig1-dev libglu1-mesa-dev libxrandr-dev libdbus-1-dev -y && \ apt install fontconfig libfontconfig1-dev libglu1-mesa-dev libxrandr-dev libdbus-1-dev -y && \
apt install openjdk-21-jdk -y && \ apt install openjdk-21-jdk -y && \
apt install gcc-10 g++-10 -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 && \
update-alternatives --config gcc && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Install chromium tools # Install chromium tools
...@@ -29,7 +32,7 @@ RUN dpkg --add-architecture arm64 && echo \ ...@@ -29,7 +32,7 @@ RUN dpkg --add-architecture arm64 && echo \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Install cross-compilation toolchain for ARM64 # Install cross-compilation toolchain for ARM64
ENV ARM_TOOLCHAIN_VERSION=9.2-2019.12 ENV ARM_TOOLCHAIN_VERSION=10.3-2021.07
ENV ARM_TOOLCHAIN_NAME=gcc-arm-${ARM_TOOLCHAIN_VERSION}-x86_64-aarch64-none-linux-gnu ENV ARM_TOOLCHAIN_NAME=gcc-arm-${ARM_TOOLCHAIN_VERSION}-x86_64-aarch64-none-linux-gnu
ENV ARM_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain ENV ARM_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain
ENV ARM_TOOLCHAIN_SYSROOT=$ARM_TOOLCHAIN_PATH/aarch64-none-linux-gnu/libc ENV ARM_TOOLCHAIN_SYSROOT=$ARM_TOOLCHAIN_PATH/aarch64-none-linux-gnu/libc
......
...@@ -6,7 +6,10 @@ ARG TARGETARCH ...@@ -6,7 +6,10 @@ ARG TARGETARCH
# Install basic & development tools # Install basic & development tools
RUN yum install -y tar xz git wget curl zip gzip && \ RUN yum install -y tar xz git wget curl zip gzip && \
yum install -y gcc gcc-c++ binutils make && \ yum install -y gcc10 gcc10-c++ gcc10-binutils make && \
ln -sf /usr/bin/gcc10-gcc /usr/bin/gcc && \
ln -sf /usr/bin/gcc10-g++ /usr/bin/g++ && \
ln -sf /usr/bin/gcc10-ar /usr/bin/ar && \
yum clean all yum clean all
# Install libraries # Install libraries
...@@ -37,7 +40,7 @@ ENV PATH=$DEPOT_TOOLS:$PATH ...@@ -37,7 +40,7 @@ ENV PATH=$DEPOT_TOOLS:$PATH
RUN git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' $DEPOT_TOOLS RUN git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' $DEPOT_TOOLS
# Install cross-compilation toolchain for ARM64 # Install cross-compilation toolchain for ARM64
ENV ARM_TOOLCHAIN_VERSION=9.2-2019.12 ENV ARM_TOOLCHAIN_VERSION=10.3-2021.07
ENV ARM_TOOLCHAIN_NAME=gcc-arm-${ARM_TOOLCHAIN_VERSION}-x86_64-aarch64-none-linux-gnu ENV ARM_TOOLCHAIN_NAME=gcc-arm-${ARM_TOOLCHAIN_VERSION}-x86_64-aarch64-none-linux-gnu
ENV ARM_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain ENV ARM_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain
ENV PATH="/usr/local/bin:$ARM_TOOLCHAIN_PATH/bin:$PATH" ENV PATH="/usr/local/bin:$ARM_TOOLCHAIN_PATH/bin:$PATH"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment