Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only add extra ldflags on linux #901

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
31 changes: 29 additions & 2 deletions boringssl-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<msvcSslLibs>ssl.lib;crypto.lib</msvcSslLibs>
<cflags>-Werror -fno-omit-frame-pointer -fvisibility=hidden -Wunused -Wno-unused-value -O3</cflags>
<cppflags>-DHAVE_OPENSSL -I${boringsslSourceDir}/include</cppflags>
<ldflags>-L${boringsslHome}/ssl -L${boringsslHome}/crypto -lssl -lcrypto -static-libstdc++ -l:libstdc++.a</ldflags>
<ldflags>-L${boringsslHome}/ssl -L${boringsslHome}/crypto -lssl -lcrypto</ldflags>
<skipJapicmp>true</skipJapicmp>
<!-- We need to use the same module name for all our "native" impls as only one should be loaded -->
<javaModuleName>${javaDefaultModuleName}</javaModuleName>
Expand Down Expand Up @@ -563,6 +563,33 @@
</configuration>
</execution>

<execution>
<id>ldflags-setup</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<!-- Add the ant tasks from ant-contrib -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<echo message="Setup flags to use during linking" />

<!-- If we compile on linux we need to adjust the ldflags to correct link libstdc++ -->
<if>
<equals arg1="${os.detected.name}" arg2="linux" />
<then>
<property name="hawtjniLdflags" value="-L${boringsslHome}/ssl -L${boringsslHome}/crypto -lssl -lcrypto -static-libstdc++ -l:libstdc++.a" />
</then>
<else>
<property name="hawtjniLdflags" value="${ldflags}" />
</else>
</if>
</target>
</configuration>
</execution>

<!-- Build the additional JAR that contains the native library. -->
<execution>
<id>native-jar</id>
Expand Down Expand Up @@ -658,7 +685,7 @@
<configureArg>${macOsxDeploymentTarget}</configureArg>
<configureArg>CFLAGS=${cflags}</configureArg>
<configureArg>CPPFLAGS=${cppflags}</configureArg>
<configureArg>LDFLAGS=${ldflags}</configureArg>
<configureArg>LDFLAGS=${hawtjniLdflags}</configureArg>
</configureArgs>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ public class NativeTest {
@Test
public void loadNativeLib() throws Exception {
String testClassesRoot = NativeTest.class.getProtectionDomain().getCodeSource().getLocation().getFile();
File f = new File(testClassesRoot + File.separator + "META-INF" + File.separator + "native");
File[] directories = new File(testClassesRoot + File.separator + "META-INF" + File.separator + "native")
.listFiles();
if (directories == null || directories.length != 1) {
throw new IllegalStateException("Could not find platform specific native directory");
throw new IllegalStateException("Could not find platform specific native directory: " + f);
}
String libName = System.mapLibraryName("netty_tcnative")
// Fix the filename (this is needed for macOS).
Expand Down
Loading