Skip to content

HDDS-15559. Add libhadoop to DYLD_LIBRARY_PATH or LD_LIBRARY_PATH - #10513

Merged
adoroszlai merged 8 commits into
apache:HDDS-10685from
ChenSammi:HDDS-15559
Jul 17, 2026
Merged

HDDS-15559. Add libhadoop to DYLD_LIBRARY_PATH or LD_LIBRARY_PATH#10513
adoroszlai merged 8 commits into
apache:HDDS-10685from
ChenSammi:HDDS-15559

Conversation

@ChenSammi

@ChenSammiChenSammi commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Currently, three platform hadoop native library is supported,

linux, x86_64
linux, aarch64
Mac, arm64(aarch64)
  1. download all three platform native library during mvn build
  2. create libhadoop.so pointing to linux x86_64 native library file during mvn build
  3. create libhadoop.dylib pointing to mac arm64 native library file during mvn build
  4. at runtime, if it's linux aarch64 platform, recreate the libhadoop.so pointing to linux aarch64 native library file
  5. add libhadoop to DYLD_LIBRARY_PATH or LD_LIBRARY_PATH, so that libhadoop can be found and loaded during Ozone service and client startup if short-circuit is enabled.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15559

How was this patch tested?

Tested locally for aarch64 platform, and CI for x86_64 platform.

// use ozone docker image hadoop native library under /usr/lib

bash-5.1$ ozone debug checknative
Native library checking:
hadoop: true /usr/lib/libhadoop.so.1.0.0
ISA-L: false libhadoop was built without ISA-L support
OpenSSL: false Cannot load libcrypto.so (libcrypto.so: cannot open shared object file: No such file or directory)!
rocks-tools: false 

// mvn clean package -DskipTests -Dmaven.javadoc.skip=true -Pdist -Plinux-aarch64 // on MacOS M1
// use ozone package hadoop native library under ./lib/native/

bash-5.1$ ozone debug checknative
Native library checking:
hadoop: true /opt/hadoop/lib/native/libhadoop_linux_aarch_64.so
ISA-L: false libhadoop was built without ISA-L support
OpenSSL: false Cannot load libcrypto.so (libcrypto.so: cannot open shared object file: No such file or directory)!
rocks-tools: false

@ChenSammi

Copy link
Copy Markdown
ContributorAuthor

@adoroszlaiadoroszlai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @ChenSammi for working on this. This change makes the build output depend on user's environment (OS, architecture). As discussed in #10305, this decision should be made at runtime, not build time. Build output should include all available libs, so user downloading binary tarball can use it on all platforms. (We also use the same tarball for creating Ozone Docker image.)

@ChenSammi

Copy link
Copy Markdown
ContributorAuthor

Thanks @ChenSammi for working on this. This change makes the build output depend on user's environment (OS, architecture). As discussed in #10305, this decision should be made at runtime, not build time. Build output should include all available libs, so user downloading binary tarball can use it on all platforms. (We also use the same tarball for creating Ozone Docker image.)

@adoroszlai , thanks for the review. These are the observations when I run ozone in docker in Mac M1,

  1. the ozone docker is linux arm64. Both linux arm64 and x86_64 expects hadoop library with name "libhadoop.so", this symbolic file is created during build time. So it cannot support both arm64 and x86_64 at build time. Unless we move the symbolic creation at run time, but still need to detect the os/architecture at runtime.
  2. The current build script, it supports auto detect os/architecture, also supports cross platform build with -P, which is needed for debug environment like mine.
  3. I inspected the hadoop release package, it has normal bin package, and arm64 bin package, each only carries the native libraries for it's architecture. I feel this way is very clean. Is there any obvious benefit that mixing all platform native libraries together in one tarball?

@adoroszlai

adoroszlai commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Is there any obvious benefit that mixing all platform native libraries together in one tarball?

Yes:

  • reduced time at release (one build)
  • reduced storage (no duplicated 500MB+ artifacts for a difference in native library less than 1MB)

ratis-thirdparty (and Ozone) binaries include Netty native libraries for all platforms.

@jojochuang

Copy link
Copy Markdown
Contributor

There's a repeated CI failure due to downloading rocksdbjni. We're updating rocksdb to 10 not sure if that's going to solve this problem. #9813

@jojochuang

Copy link
Copy Markdown
Contributor

My Cursor is fixing the native lib problem: https://github.com/jojochuang/ozone/commits/refs/heads/HDDS-15559/

@ChenSammiChenSammi changed the title HDDS-15559. Enable cross platform hadoop native library downloadHDDS-15559. Create libhadoop symbolic link at runtimeJul 15, 2026
@ChenSammi
ChenSammiforce-pushed the HDDS-15559 branch 2 times, most recently from 5554ef6 to b7c5094CompareJuly 16, 2026 04:04
@adoroszlai

Copy link
Copy Markdown
Contributor

Can we please keep it as draft until CI is passing in fork?

@ChenSammiChenSammi changed the title HDDS-15559. Create libhadoop symbolic link at runtimeHDDS-15559. Fix libhadoop symbolic link at runtimeJul 16, 2026
@ChenSammiChenSammi changed the title HDDS-15559. Fix libhadoop symbolic link at runtimeHDDS-15559. Add libhadoop to DYLD_LIBRARY_PATH or LD_LIBRARY_PATHJul 16, 2026
@ChenSammi

Copy link
Copy Markdown
ContributorAuthor

@adoroszlai@jojochuang , could you help to review the patch again?

@yandrey321

Copy link
Copy Markdown
Contributor

My Cursor is fixing the native lib problem: https://github.com/jojochuang/ozone/commits/refs/heads/HDDS-15559/

is it a fix for m1/arm environments?

# Forcefully recreate it so it points to the correct target file
ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1
fi
export DYLD_LIBRARY_PATH=$OZONE_HOME/lib/native:$DYLD_LIBRARY_PATH

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would this export be effective to the current build/test execution process?

@ChenSammiChenSammiJul 17, 2026

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is mainly for the Mac user of final ozone bin package.

@adoroszlaiadoroszlai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @ChenSammi for getting this to work. I have some minor code comments, I will address them in follow-up.

Comment threadhadoop-ozone/dist/src/shell/ozone/ozone-functions.sh
pushd . > /dev/null && cd lib/native
# If no matching file variant was found for the current environment
if [ -z "$TARGET_FILE" ]; then
echo "Error: libhadoop doesn't support platform combination ($OS_TYPE / $ARCH_TYPE)." >&2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OS_TYPE is deprecated, should use OZONE_OS_TYPE.

if [ -z "$TARGET_FILE" ]; then
echo "Error: libhadoop doesn't support platform combination ($OS_TYPE / $ARCH_TYPE)." >&2
else
LINK_FILE="libhadoop.dylib"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By moving LINK_FILE definition out of if-else, the code block can be extracted to a function, to be reused for both Darwin and Linux cases.

Co-authored-by: Doroszlai, Attila <6454655+adoroszlai@users.noreply.github.com>
@adoroszlai
adoroszlai merged commit 2777374 into apache:HDDS-10685Jul 17, 2026
45 checks passed
@ChenSammi

Copy link
Copy Markdown
ContributorAuthor

Thanks @adoroszlai@jojochuang@yandrey321 , for the review and good suggestion.

Sign up for freeto 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

@ChenSammi@adoroszlai@jojochuang@yandrey321