|
579 | 579 | <echo message="Setup flags to use during linking" /> |
580 | 580 |
|
581 | 581 | <!-- 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. --> |
582 | 587 | <if> |
583 | 588 | <equals arg1="${os.detected.name}" arg2="linux" /> |
584 | 589 | <then> |
|
618 | 623 | </then> |
619 | 624 | </if> |
620 | 625 |
|
| 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 | + |
621 | 646 | <copy todir="${nativeJarWorkdir}"> |
622 | 647 | <zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" /> |
623 | 648 | </copy> |
|
925 | 950 | </then> |
926 | 951 | </if> |
927 | 952 |
|
| 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 | + |
928 | 970 | <copy todir="${nativeJarWorkdir}"> |
929 | 971 | <zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" /> |
930 | 972 | </copy> |
|