-
Notifications
You must be signed in to change notification settings - Fork 85
Add support for AIX in build process #297
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
base: master
Are you sure you want to change the base?
Changes from 9 commits
be134be
34d19fb
75d1168
dbd4f34
6a3c0c8
d54c269
c9d5ec9
847e9bf
a94e0a3
73da4b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,6 @@ if (clang_versions.length == 0) { | |
| " Make sure a ${llvm_home}/lib/clang/<VERSION> directory exists") | ||
| } | ||
| def clang_version = clang_versions[0] | ||
|
|
||
| def buildDir = layout.buildDirectory.get() | ||
| def jextract_version = "23" | ||
| def jmods_dir = "$buildDir/jmods" | ||
|
|
@@ -73,24 +72,32 @@ jar { | |
| task copyLibClang(type: Sync) { | ||
| into("$buildDir/jmod_inputs") | ||
|
|
||
| // make sure we only pick up the "real" shared library file from LLVM installation | ||
| // (e.g. exclude symlinks on Linux) | ||
| def clang_path_include = (Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC)) ? | ||
| "libclang.so.${clang_version}" : "*clang*" | ||
|
|
||
| from("${libclang_dir}") { | ||
| include(clang_path_include) | ||
| include("libLLVM.*") | ||
| exclude("clang.exe") | ||
| into("libs") | ||
| // make sure we drop shared library version name (Linux only) | ||
| rename("libclang.so.${clang_version}", "libclang.so") | ||
| } | ||
|
|
||
| from("$clang_include_dir") { | ||
| // make sure we only pick up the "real" shared library file from LLVM installation | ||
| // (e.g. exclude symlinks on Linux) | ||
| def isAix = Os.isName("AIX") || Os.isName("aix") | ||
| def isUnixNotMac = Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC) | ||
| def clang_path_include = | ||
| isAix ? "libclang.a" : | ||
| isUnixNotMac ? "libclang.so.${clang_version}" : | ||
| "*clang*" | ||
| from("${libclang_dir}") { | ||
| include(clang_path_include) | ||
| include("libLLVM.*") | ||
| exclude("clang.exe") | ||
| into("libs") | ||
| // make sure we drop shared library version name (Linux only) | ||
| rename("libclang.so.*", "libclang.so") | ||
|
|
||
| } | ||
| from("${libclang_dir}") { | ||
| include("libclang.a") | ||
| into("$buildDir/test-libs") | ||
| } | ||
|
Comment on lines
+92
to
+95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right. This task is meant from creating the jmod inputs, not for setting up tests. This shouldn't be needed any way, since the tests are run on a runtime image that includes the library already. |
||
| from("$clang_include_dir") { | ||
| include("*.h") | ||
| into("conf/jextract") | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| task createJextractJmod(type: Exec) { | ||
|
|
@@ -194,6 +201,8 @@ task createRuntimeImageForTest(type: Exec) { | |
|
|
||
| task cmakeConfigure(type: Exec) { | ||
| executable = "cmake" | ||
| environment "CC", "/opt/IBM/xlC/13.1.3/bin/xlc" | ||
| environment "CXX", "/opt/IBM/xlC/13.1.3/bin/xlC" | ||
|
||
| args = [ | ||
| "-B", "$buildDir/testlib-build", | ||
| "-S", "$projectDir/test/test-support", | ||
|
|
@@ -203,6 +212,7 @@ task cmakeConfigure(type: Exec) { | |
| ] | ||
| } | ||
|
|
||
|
|
||
| task cmakeBuild(type: Exec) { | ||
| dependsOn cmakeConfigure | ||
|
|
||
|
|
@@ -238,7 +248,7 @@ void createJtregTask(String name, String jacocoAgent, String os_lib_dir) { | |
| "-javacoption:--add-exports=org.openjdk.jextract/org.openjdk.jextract.json.parser=ALL-UNNAMED", | ||
| "-javaoption:--add-exports=org.openjdk.jextract/org.openjdk.jextract.json.parser=ALL-UNNAMED", | ||
| "-avm", "-conc:auto", "-verbose:summary,fail,error", | ||
| "-retain:fail,error", | ||
| "-retain:fail,error" | ||
| ] | ||
|
|
||
| if (jacocoAgent != null) { | ||
|
|
@@ -258,6 +268,24 @@ if (jacocoAgent != null) { | |
| createJtregTask("jtregWithCoverage", jacocoAgent, os_lib_dir) | ||
| } | ||
|
|
||
|
|
||
| tasks.register("copyLibClangToTestLib", Copy) { | ||
| def srcFile = file("${project.buildDir}/jmod_inputs/libs/libclang.a") | ||
| def destDir = file("${project.buildDir}/test-lib/libs") | ||
| dependsOn(copyLibClang) | ||
| from(srcFile) | ||
| into(destDir) | ||
|
|
||
| doLast { | ||
| println "[DEBUG] Successfully copied libclang.a to test-lib/libs" | ||
| } | ||
suchismith1993 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // Make jtreg depend on it | ||
| tasks.named("jtreg") { | ||
| dependsOn("copyLibClangToTestLib") | ||
| } | ||
|
|
||
| tasks.register("coverage", JavaExec) { | ||
| dependsOn jtregWithCoverage | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,39 +68,53 @@ endef | |
|
|
||
| X := | ||
| SPACE:=$(X) $(X) | ||
|
|
||
| UNAME_P := $(shell uname -p) | ||
| UNAME_M := $(shell uname -m) | ||
|
|
||
| # CPU detection | ||
| ifeq ($(UNAME_M),x86_64) | ||
| DEVKIT_VS_CPU_VAR_NAME := x86_64 | ||
| PLATFORM_CPU := x64 | ||
| else ifeq ($(UNAME_M),arm64) | ||
| DEVKIT_VS_CPU_VAR_NAME := aarch64 | ||
| PLATFORM_CPU := aarch64 | ||
| else ifeq ($(UNAME_M),aarch64) | ||
| DEVKIT_VS_CPU_VAR_NAME := aarch64 | ||
| PLATFORM_CPU := aarch64 | ||
| DEVKIT_VS_CPU_VAR_NAME := x86_64 | ||
| PLATFORM_CPU := x64 | ||
| else | ||
| $(error "Unknown CPU: $(UNAME_M)") | ||
| ifeq ($(UNAME_M),arm64) | ||
| DEVKIT_VS_CPU_VAR_NAME := aarch64 | ||
| PLATFORM_CPU := aarch64 | ||
| else | ||
| ifeq ($(UNAME_M),aarch64) | ||
| DEVKIT_VS_CPU_VAR_NAME := aarch64 | ||
| PLATFORM_CPU := aarch64 | ||
| else | ||
| ifeq ($(UNAME_P),powerpc) | ||
| DEVKIT_VS_CPU_VAR_NAME := ppc64 | ||
| PLATFORM_CPU := ppc64 | ||
| else | ||
| $(error "Unknown CPU: $(UNAME_M)") | ||
| endif | ||
| endif | ||
| endif | ||
| endif | ||
|
Comment on lines
75
to
95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo the format changes. |
||
|
|
||
| # OS detection | ||
| ifeq ($(OS),Windows_NT) | ||
| PLATFORM_OS := windows | ||
| FIXPATH := bash $(TOPDIR)/make/scripts/fixpath.sh exec | ||
| PLATFORM_OS := windows | ||
| FIXPATH := bash $(TOPDIR)/make/scripts/fixpath.sh exec | ||
| else | ||
| FIXPATH := | ||
|
|
||
| UNAME_S := $(shell uname -s) | ||
| ifeq ($(UNAME_S), Darwin) | ||
| PLATFORM_OS := macosx | ||
| else | ||
| ifeq ($(UNAME_S), Linux) | ||
| PLATFORM_OS := linux | ||
| FIXPATH := | ||
| UNAME_S := $(shell uname -s) | ||
| ifeq ($(UNAME_S),Darwin) | ||
| PLATFORM_OS := macosx | ||
| else | ||
| $(error "Unknown OS: $(UNAME_S)") | ||
| ifeq ($(UNAME_S),Linux) | ||
| PLATFORM_OS := linux | ||
| else | ||
| ifeq ($(UNAME_S),AIX) | ||
| PLATFORM_OS := aix | ||
| else | ||
| $(error "Unknown OS: $(UNAME_S)") | ||
| endif | ||
| endif | ||
| endif | ||
| endif | ||
| endif | ||
|
|
||
| PLATFORM := $(PLATFORM_OS)-$(PLATFORM_CPU) | ||
|
|
||
| ECHO := echo | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,9 +33,10 @@ | |
| import java.util.*; | ||
| import java.util.function.*; | ||
| import java.util.stream.*; | ||
|
|
||
| import static java.lang.foreign.ValueLayout.*; | ||
| import java.util.StringTokenizer; | ||
| import static java.lang.foreign.MemoryLayout.PathElement.*; | ||
| import java.io.File; | ||
|
|
||
| public class Index_h { | ||
|
|
||
|
|
@@ -80,15 +81,34 @@ static MemoryLayout align(MemoryLayout layout, long align) { | |
| }; | ||
| } | ||
|
|
||
| static SymbolLookup SYMBOL_LOOKUP; | ||
|
|
||
| static { | ||
| String libName = System.getProperty("os.name").startsWith("Windows") ? "libclang" : "clang"; | ||
| System.loadLibrary(libName); | ||
| String osName = System.getProperty("os.name"); | ||
| String libName = ""; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable doesn't look like it needs to be hoisted. |
||
| if (osName.startsWith("AIX")) { | ||
| List<String> pathsToCheck = new ArrayList<>(Arrays.asList( | ||
| System.getProperty("java.library.path").split(File.pathSeparator) | ||
| )); | ||
| // 2. Add alternate calculated paths | ||
| String currentDir = System.getProperty("user.dir"); // wherever JVM was launched | ||
| pathsToCheck.add(currentDir + "/build/jextract-jdk-test-image/lib"); | ||
| pathsToCheck.add(currentDir + "/../../../jextract-jdk-test-image/lib"); // in case running from subdir | ||
| // 3. Try to find the library | ||
| for (String path : pathsToCheck) { | ||
| File f = new File(path, "libclang.a"); // AIX uses .a, Linux .so | ||
| if (f.exists() && !f.isDirectory()) { | ||
| libName = f.getAbsolutePath(); | ||
| break; | ||
| } | ||
| } | ||
| SYMBOL_LOOKUP = SymbolLookup.libraryLookup(libName + "(libclang.so.14)", Arena.global()); | ||
|
Comment on lines
+90
to
+105
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pleas fix the indentation here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, hard-coding paths the the build directories in the production code seems fishy. It also shouldn't be needed. If the library is properly included in the runtime image, that's where it can be found, and I'm expecting the call to If it doesn't then there's something wrong with the runtime image. You might want to test grabbing the .jmod file from the build, and creating another runtime image with it, and then trying to access some of the jextract API classes in e.g. a jshell session, to see if the library can be loaded. |
||
| } else { | ||
| libName = osName.startsWith("Windows") ? "libclang" : "clang"; | ||
| System.loadLibrary(libName); | ||
| SYMBOL_LOOKUP = SymbolLookup.loaderLookup().or(Linker.nativeLinker().defaultLookup()); | ||
| } | ||
| } | ||
|
|
||
| static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() | ||
| .or(Linker.nativeLinker().defaultLookup()); | ||
|
|
||
| public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; | ||
| public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; | ||
| public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.14) | |||||||||||||||
| project(TestSupportLibs) | ||||||||||||||||
|
|
||||||||||||||||
| option(TEST_SOURCE_ROOT "src directory with test files") | ||||||||||||||||
|
|
||||||||||||||||
| file(GLOB_RECURSE TEST_LIBS ${TEST_SOURCE_ROOT}/*lib*.c) | ||||||||||||||||
|
|
||||||||||||||||
| foreach(TEST_LIB ${TEST_LIBS}) | ||||||||||||||||
|
|
@@ -11,13 +10,26 @@ foreach(TEST_LIB ${TEST_LIBS}) | |||||||||||||||
| string(REGEX REPLACE ".*lib([A-Za-z0-9_]+)\.c(pp)?" "\\1" LIB_NAME ${TEST_LIB}) | ||||||||||||||||
| string(REGEX REPLACE "(.*)/lib[A-Za-z0-9_]+\.c(pp)?" "\\1" PARENT_DIR ${TEST_LIB}) | ||||||||||||||||
| message(STATUS "Lib name: ${LIB_NAME}") | ||||||||||||||||
| if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") | ||||||||||||||||
| add_library(${LIB_NAME} SHARED ${TEST_LIB}) | ||||||||||||||||
| set_target_properties(${LIB_NAME} PROPERTIES | ||||||||||||||||
| PREFIX "lib" | ||||||||||||||||
| SUFFIX ".a" | ||||||||||||||||
| COMPILE_FLAGS "-q64 -qhalt=e" | ||||||||||||||||
| LINK_FLAGS "-q64 -G -Wl,-bnoentry,-bexpall" | ||||||||||||||||
| ) | ||||||||||||||||
| else() | ||||||||||||||||
| add_library(${LIB_NAME} SHARED ${TEST_LIB}) | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| add_library(${LIB_NAME} SHARED ${TEST_LIB}) | ||||||||||||||||
| target_include_directories(${LIB_NAME} | ||||||||||||||||
| PRIVATE | ||||||||||||||||
| ${PARENT_DIR} | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| # Link against libm to resolve sqrt() and other math symbols | ||||||||||||||||
| target_link_libraries(${LIB_NAME} m) | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+30
to
+32
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work on Windows:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you could use something like:
Suggested change
|
||||||||||||||||
| install( | ||||||||||||||||
| TARGETS | ||||||||||||||||
| ${LIB_NAME} | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean up the spurious white space changes from the patch.