GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make the Linux artifacts loadable on musl (Alpine) again · netty/netty-tcnative@f55e968

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • boringssl-static
    • pom.xml
  • docker
    • Dockerfile.centos6
    • Dockerfile.cross_compile_aarch64
  • docs
    • musl-compatibility.md
  • openssl-dynamic/src/main/c
    • musl_compat.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎boringssl-static/pom.xml‎

Copy file name to clipboardExpand all lines: boringssl-static/pom.xml
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@
579579
<echo message="Setup flags to use during linking" />
580580

581581
<!-- If we compile on linux we need to adjust the ldflags to correct link libstdc++ -->
582+
<!-- NOTE: -static-libgcc was tried here to drop the DT_NEEDED on libgcc_s.so.1
583+
(not a musl-reserved name). It is a no-op in this build: the library is linked
584+
with the C driver, so the _Unwind_* symbols pulled in by libstdc++.a stay
585+
undefined and libgcc_s.so.1 remains genuinely required. Alpine satisfies it
586+
with the `libgcc` package, which the JDK images already install. -->
582587
<if>
583588
<equals arg1="${os.detected.name}" arg2="linux" />
584589
<then>
@@ -618,6 +623,26 @@
618623
</then>
619624
</if>
620625

626+
<!-- Drop the DT_NEEDED on ld-linux-<arch>.so. It gets recorded because
627+
__tls_get_addr lives in glibc's loader, but musl defines that symbol itself,
628+
so only the filename lookup fails - on Alpine the library is unloadable
629+
purely because of this entry. Removing it is a no-op on glibc, where the
630+
loader is already mapped. patchelf exits 0 when the entry is absent, so this
631+
is safe on architectures that never had it. Same approach as async-profiler.
632+
See https://github.com/netty/netty-tcnative/issues/907 -->
633+
<if>
634+
<equals arg1="${os.detected.name}" arg2="linux" />
635+
<then>
636+
<exec executable="patchelf" failonerror="true" dir="${nativeLibOnlyDir}/META-INF/native/linux${archBits}/" resolveexecutable="true">
637+
<arg value="--remove-needed" />
638+
<arg value="ld-linux-x86-64.so.2" />
639+
<arg value="--remove-needed" />
640+
<arg value="ld-linux-aarch64.so.1" />
641+
<arg value="libnetty_tcnative.so" />
642+
</exec>
643+
</then>
644+
</if>
645+
621646
<copy todir="${nativeJarWorkdir}">
622647
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
623648
</copy>
@@ -925,6 +950,23 @@
925950
</then>
926951
</if>
927952

953+
<!-- Same ld-linux DT_NEEDED removal as the default profile, so both released
954+
Linux artifacts get it. patchelf is arch-agnostic, so the x86_64 host tool
955+
edits the cross-built aarch64 object fine, and it exits 0 when the entry is
956+
absent. See docs/musl-compatibility.md -->
957+
<if>
958+
<equals arg1="${os.detected.name}" arg2="linux" />
959+
<then>
960+
<exec executable="patchelf" failonerror="true" dir="${nativeLibOnlyDir}/META-INF/native/linux${archBits}/" resolveexecutable="true">
961+
<arg value="--remove-needed" />
962+
<arg value="ld-linux-x86-64.so.2" />
963+
<arg value="--remove-needed" />
964+
<arg value="ld-linux-aarch64.so.1" />
965+
<arg value="libnetty_tcnative.so" />
966+
</exec>
967+
</then>
968+
</if>
969+
928970
<copy todir="${nativeJarWorkdir}">
929971
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
930972
</copy>
Collapse file

‎docker/Dockerfile.centos6‎

Copy file name to clipboardExpand all lines: docker/Dockerfile.centos6
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV CMAKE_VERSION $CMAKE_VERSION_BASE.4
1010
ENV NINJA_VERSION 1.7.2
1111
ENV GO_VERSION 1.9.3
1212
ENV MAVEN_VERSION 3.9.1
13+
ENV PATCHELF_VERSION 0.18.0
1314

1415
# Update as we need to use the vault now.
1516
RUN sed -i -e 's/^mirrorlist/#mirrorlist/g' -e 's/^#baseurl=http:\/\/mirror.centos.org\/centos\/$releasever\//baseurl=https:\/\/linuxsoft.cern.ch\/centos-vault\/\/6.10\//g' /etc/yum.repos.d/CentOS-Base.repo
@@ -68,6 +69,17 @@ RUN set -x && \
6869
make -j1 install_sw) && \
6970
rm -rf openssl-$OPENSSL_VERSION openssl-$OPENSSL_VERSION.tar.gz
7071

72+
# patchelf is used post-link to drop the DT_NEEDED on ld-linux-x86-64.so.2 so the artifact
73+
# also loads under musl. CentOS 6 is EOL and has no EPEL, so install the upstream prebuilt
74+
# static binary rather than going through yum.
75+
# --no-check-certificate for the same reason as the OpenSSL download above.
76+
RUN wget -q --no-check-certificate https://github.com/NixOS/patchelf/releases/download/$PATCHELF_VERSION/patchelf-$PATCHELF_VERSION-x86_64.tar.gz \
77+
&& mkdir -p /opt/patchelf-$PATCHELF_VERSION \
78+
&& tar zxf patchelf-$PATCHELF_VERSION-x86_64.tar.gz -C /opt/patchelf-$PATCHELF_VERSION \
79+
&& ln -s /opt/patchelf-$PATCHELF_VERSION/bin/patchelf /usr/local/bin/patchelf \
80+
&& rm -f patchelf-$PATCHELF_VERSION-x86_64.tar.gz \
81+
&& patchelf --version
82+
7183
RUN rm -rf $SOURCE_DIR
7284

7385
# Downloading and installing perlbrew as we need a more up to date perl version for boringssl
Collapse file

‎docker/Dockerfile.cross_compile_aarch64‎

Copy file name to clipboardExpand all lines: docker/Dockerfile.cross_compile_aarch64
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN sed -i -e 's/^mirrorlist/#mirrorlist/g' -e 's/^#baseurl=http:\/\/mirror.cent
2222
# Install requirements
2323
RUN set -x && \
2424
yum -y install epel-release && \
25-
yum -y install wget tar git make autoconf automake libtool openssl-devel ninja-build gcc-c++ patch unzip zip which perl perl-IPC-Cmd perl-Time-Piece
25+
yum -y install wget tar git make autoconf automake libtool openssl-devel ninja-build gcc-c++ patch unzip zip which perl perl-IPC-Cmd perl-Time-Piece patchelf
2626

2727
# Install Java
2828
RUN yum install -y java-1.8.0-openjdk-devel golang

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.