Skip to content

Commit 1d2a434

Browse files
authored
[AIX]Blocking the call of dladdr under _AIX (#26513)
### Description In AIX, dladdr() is not supported so blocking the call of dladdr API under _AIX. we don't have support of cpuinfo pkg also which generates a warning at runtime. This PR is to fox the issues mentioned above. ### Motivation and Context 1. Fix for below compilation error ``` /home/buildusr/jenkins/workspace/onnxruntime-openxl/onnxruntime/onnxruntime/core/platform/posix/env.cc:562:9: error: unknown type name 'Dl_info' 562 | if (Dl_info dl_info{}; ``` 2. Fix for below warning during test application executions. `2025-11-06 07:23:44.176700000 [W:onnxruntime:Default, cpuid_info.cc:95 LogEarlyWarning] Unknown CPU vendor. cpuinfo_vendor value: 0`
1 parent 4dbb05f commit 1d2a434

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

cmake/onnxruntime_unittests.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,14 @@ endif()
15281528
onnxruntime_add_shared_library(onnxruntime_runtime_path_test_shared_library
15291529
${onnxruntime_runtime_path_test_shared_library_src})
15301530

1531-
target_link_libraries(onnxruntime_runtime_path_test_shared_library PRIVATE
1532-
onnxruntime_common cpuinfo ${CMAKE_DL_LIBS})
1531+
if (CMAKE_SYSTEM_NAME MATCHES "AIX")
1532+
target_link_libraries(onnxruntime_runtime_path_test_shared_library PRIVATE
1533+
onnxruntime_common ${CMAKE_DL_LIBS})
1534+
set_target_properties(onnxruntime_runtime_path_test_shared_library PROPERTIES AIX_SHARED_LIBRARY_ARCHIVE OFF)
1535+
else()
1536+
target_link_libraries(onnxruntime_runtime_path_test_shared_library PRIVATE
1537+
onnxruntime_common cpuinfo ${CMAKE_DL_LIBS})
1538+
endif()
15331539
target_include_directories(onnxruntime_runtime_path_test_shared_library PRIVATE ${ONNXRUNTIME_ROOT})
15341540

15351541
if(UNIX)

onnxruntime/core/common/cpuid_info_vendor.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ constexpr std::array kCpuVendorInfos{
198198
CpuVendorInfo{cpuinfo_vendor_nvidia, "Nvidia", 0x10DE},
199199
CpuVendorInfo{cpuinfo_vendor_apple, "Apple", 0x106B},
200200
CpuVendorInfo{cpuinfo_vendor_arm, "ARM", 0x13B5},
201-
201+
CpuVendorInfo{cpuinfo_vendor_ibm, "IBM", 0x1014},
202202
// TODO add more as needed
203203
};
204204

@@ -228,6 +228,9 @@ void CPUIDInfo::VendorInfoInit() {
228228
}
229229
}
230230
#endif // defined(CPUINFO_SUPPORTED)
231+
#if defined(_AIX)
232+
result = cpuinfo_vendor_ibm;
233+
#endif
231234
return result;
232235
}();
233236

onnxruntime/core/platform/posix/env.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ class PosixEnv : public Env {
556556
}
557557

558558
PathString GetRuntimePath() const override {
559+
// In AIX, dladdr is not supported.
560+
#if !defined(_AIX)
559561
// Use dladdr() to look up the file that contains an address from this binary.
560562
const void* const address_from_this_binary = reinterpret_cast<const void*>(Env::Default);
561563

@@ -568,7 +570,7 @@ class PosixEnv : public Env {
568570
runtime_path.remove_filename();
569571
return runtime_path;
570572
}
571-
573+
#endif
572574
return PathString{};
573575
}
574576

onnxruntime/test/shared_lib/test_runtime_path.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ bool IsDirectorySeparator(PathChar c) {
2121
}
2222
} // namespace
2323

24+
#if !defined(_AIX)
2425
TEST(GetRuntimePathFromSharedLibraryTest, Basic) {
26+
#else
27+
TEST(GetRuntimePathFromSharedLibraryTest, DISABLED_Basic) {
28+
#endif
2529
const auto* runtime_path_cstr = OrtTestGetSharedLibraryRuntimePath();
2630
ASSERT_NE(runtime_path_cstr, nullptr);
2731

0 commit comments

Comments
 (0)