From 1fad606022f619a09ad1ba5cd469dfcd5fa45ec2 Mon Sep 17 00:00:00 2001 From: Sicong Liu Date: Mon, 10 Aug 2026 16:57:03 -0700 Subject: [PATCH 1/3] Stop linking libc++ into the Java extension on Linux libJavaExtension.so.1.0 shipped with these runtime dependencies: libc++.so.1 libc++abi.so.1 libunwind.so.1 libstdc++.so.6 libc.so.6 The target is compiled with GCC and therefore already links GNU libstdc++, so the explicit libc++ / libc++abi linkage put two C++ runtimes in one .so and dragged in libunwind through libc++abi. None of those three are libraries the SQL container images are required to ship. RHEL images carry none of them, so the Java extension never loaded there: Exthost: Load extension failed libunwind.so.1: cannot open shared object file That produced 15 'Java' script errors plus 7 cascading KeyNotFoundException on both RHEL 9 and RHEL 10 - 22 failures, identical on each. Ubuntu passed only because its images happen to carry libc++, libc++abi and libunwind. Python and R link libstdc++ alone; Java now matches them. Same defect class as the dynamic Boost dependency fixed in #107: a find_library resolving something the runtime images do not provide, invisible to a green build. Linux-only - the change sits inside if(PLATFORM STREQUAL linux) and the Windows branch is untouched. No source files change. --- language-extensions/java/src/CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/language-extensions/java/src/CMakeLists.txt b/language-extensions/java/src/CMakeLists.txt index 928cc9be..8db645c6 100644 --- a/language-extensions/java/src/CMakeLists.txt +++ b/language-extensions/java/src/CMakeLists.txt @@ -66,11 +66,20 @@ if (${PLATFORM} STREQUAL linux) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -shared -L${OUTPUT_DIRECTORY}/lib -L${LIBS} -Wl,-rpath,${JRE_ROOT}:/opt/mssql-extensibility/lib") set(USR_LIB_PATH "/usr/local/lib") - find_library(CXX_LIB c++ ${USR_LIB_PATH}) - find_library(ABI_LIB c++abi ${USR_LIB_PATH}) + # Do NOT link LLVM's libc++ / libc++abi here. This target is compiled with GCC, so it + # already links GNU libstdc++; adding libc++ put two C++ runtimes in one .so and, via + # libc++abi, pulled in libunwind. That made libc++.so.1, libc++abi.so.1 and + # libunwind.so.1 runtime dependencies which the SQL container images are not required + # to ship. RHEL images carry none of them, so the Java extension failed to load there + # on every distro release: + # + # Exthost: Load extension failed libunwind.so.1: cannot open shared object file + # + # Ubuntu only worked by accident, because its images happen to carry those libraries. + # Python and R link libstdc++ alone; Java now matches them. find_library(DL_LIB dl ${USR_LIB_PATH}) - target_link_libraries(JavaExtension ${CXX_LIB} ${ABI_LIB} ${DL_LIB}) + target_link_libraries(JavaExtension ${DL_LIB}) set(ADDITIONAL_INCLUDES ${JDK_INCLUDE} ${JDK_INCLUDE_LINUX}) elseif(${PLATFORM} STREQUAL windows) From 1d1e6f76d81c586b625645b87b83de2d3946fa48 Mon Sep 17 00:00:00 2001 From: Sicong Liu Date: Tue, 11 Aug 2026 10:32:12 -0700 Subject: [PATCH 2/3] Trim the comment --- language-extensions/java/src/CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/language-extensions/java/src/CMakeLists.txt b/language-extensions/java/src/CMakeLists.txt index 8db645c6..a4a73df5 100644 --- a/language-extensions/java/src/CMakeLists.txt +++ b/language-extensions/java/src/CMakeLists.txt @@ -66,17 +66,12 @@ if (${PLATFORM} STREQUAL linux) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -shared -L${OUTPUT_DIRECTORY}/lib -L${LIBS} -Wl,-rpath,${JRE_ROOT}:/opt/mssql-extensibility/lib") set(USR_LIB_PATH "/usr/local/lib") - # Do NOT link LLVM's libc++ / libc++abi here. This target is compiled with GCC, so it - # already links GNU libstdc++; adding libc++ put two C++ runtimes in one .so and, via - # libc++abi, pulled in libunwind. That made libc++.so.1, libc++abi.so.1 and - # libunwind.so.1 runtime dependencies which the SQL container images are not required - # to ship. RHEL images carry none of them, so the Java extension failed to load there - # on every distro release: + # Do NOT link LLVM's libc++ / libc++abi. This target is compiled with GCC and already + # links GNU libstdc++, so adding libc++ put two C++ runtimes in one .so and pulled in + # libunwind through libc++abi. The SQL container images are not required to ship any of + # the three, and RHEL images carry none of them: # # Exthost: Load extension failed libunwind.so.1: cannot open shared object file - # - # Ubuntu only worked by accident, because its images happen to carry those libraries. - # Python and R link libstdc++ alone; Java now matches them. find_library(DL_LIB dl ${USR_LIB_PATH}) target_link_libraries(JavaExtension ${DL_LIB}) From 54294ac7784f1ba765dfbe808b0e0a80f2edd78f Mon Sep 17 00:00:00 2001 From: Sicong Liu Date: Tue, 11 Aug 2026 10:34:22 -0700 Subject: [PATCH 3/3] State the invariant the link list maintains --- language-extensions/java/src/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/language-extensions/java/src/CMakeLists.txt b/language-extensions/java/src/CMakeLists.txt index a4a73df5..64de29f5 100644 --- a/language-extensions/java/src/CMakeLists.txt +++ b/language-extensions/java/src/CMakeLists.txt @@ -66,12 +66,10 @@ if (${PLATFORM} STREQUAL linux) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -shared -L${OUTPUT_DIRECTORY}/lib -L${LIBS} -Wl,-rpath,${JRE_ROOT}:/opt/mssql-extensibility/lib") set(USR_LIB_PATH "/usr/local/lib") - # Do NOT link LLVM's libc++ / libc++abi. This target is compiled with GCC and already - # links GNU libstdc++, so adding libc++ put two C++ runtimes in one .so and pulled in - # libunwind through libc++abi. The SQL container images are not required to ship any of - # the three, and RHEL images carry none of them: - # - # Exthost: Load extension failed libunwind.so.1: cannot open shared object file + # Keep this .so dependent only on the C/C++ runtime every SQL container image provides: + # libstdc++, libgcc_s and libc, which GCC supplies for us, plus libdl linked below. + # Any other library named here becomes a runtime dependency the images must also carry, + # and they are not required to - RHEL images ship no LLVM runtime, for example. find_library(DL_LIB dl ${USR_LIB_PATH}) target_link_libraries(JavaExtension ${DL_LIB})