Skip to content

Add xgboost4j support FreeBSD#12222

Open
huanghwh wants to merge 2 commits into
dmlc:masterfrom
huanghwh:master
Open

Add xgboost4j support FreeBSD#12222
huanghwh wants to merge 2 commits into
dmlc:masterfrom
huanghwh:master

Conversation

@huanghwh
Copy link
Copy Markdown

@huanghwh huanghwh commented May 24, 2026

I use this command to build and test:

#!/bin/sh
cmake -B build -S . -GNinja \
  -DCMAKE_C_FLAGS="-I/usr/local/include" \
  -DCMAKE_CXX_FLAGS="-I/usr/local/include" \
  -DCMAKE_EXE_LINKER_FLAGS="-ldmlc -L/usr/local/lib" \
  -DCMAKE_SHARED_LINKER_FLAGS="-ldmlc -L/usr/local/lib -Wl,-s" \
  -DBUILD_WITH_SYSTEM_DMLC=ON -DJVM_BINDINGS=ON
cd build && ninja
export JAVA_HOME=/usr/local/openjdk17
cd ../jvm-packages && mvn install -DskipTests=true

@wbo4958
Copy link
Copy Markdown
Contributor

wbo4958 commented May 25, 2026

@trivialfis @hcho3, would you help check it?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds FreeBSD as a supported platform for the XGBoost JVM bindings by teaching the Java native library loader and JNI packaging script to recognize and place FreeBSD native artifacts under the expected resource path.

Changes:

  • Add FREEBSD to NativeLibLoader.OS and OS detection logic, and include a FreeBSD-specific OpenMP dependency hint on load failure.
  • Update the JNI build/packaging script to copy the native library into a freebsd/<arch> resource directory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/NativeLibLoader.java Adds FreeBSD OS enum/detection and updates supported-OS docs + load-failure messaging.
jvm-packages/create_jni.py Adds FreeBSD mapping so the built .so is copied into the correct freebsd resources folder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 62 to 72
static OS detectOS() {
String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if (os.contains("mac") || os.contains("darwin")) {
return MACOS;
} else if (os.contains("win")) {
return WINDOWS;
} else if (os.contains("nux")) {
return LINUX;
} else if (os.contains("freebsd")) {
return FREEBSD;
} else if (os.contains("sunos")) {
break;
case FREEBSD:
logger.error(failureMessageIncludingOpenMPHint);
logger.error("You may need to install 'libomp.so'");
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In FreeBSD, libomp.so is in base system, no libgomp.so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants