Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sulong/ci/ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ local sc = (import "ci_common/sulong-common.jsonnet");
$.sulong + $.gate(standalone=true) + sc.labsjdkLatest + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.requireGCC + sc.gateTags("build,sulongMisc,parser") + $.sulong_test_toolchain + { name: "gate-sulong-misc-parser-jdk-latest-linux-amd64" },
$.sulong + $.gate() + sc.labsjdkLatest + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.gateTags("build,gcc_c") + { name: "gate-sulong-gcc_c-jdk-latest-linux-amd64", timelimit: "45:00" },
$.sulong + $.gate() + sc.labsjdkLatest + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.gateTags("build,gcc_cpp") + { name: "gate-sulong-gcc_cpp-jdk-latest-linux-amd64", timelimit: "45:00" },
$.sulong + $.gate() + sc.labsjdkLatest + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.requireGCC + sc.gateTags("build,gcc_fortran") + { name: "gate-sulong-gcc_fortran-jdk-latest-linux-amd64" },

$.sulong + $.gate() + sc.labsjdkLatest + sc.darwin_amd64 + sc.llvmBundled + sc.gateTags(basicTags) + { name: "gate-sulong-basic-nwcc-llvm-jdk-latest-darwin-amd64", timelimit: "0:45:00", capabilities+: ["ram16gb"] },

Expand Down
5 changes: 0 additions & 5 deletions sulong/ci/ci_common/sulong-common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,11 @@ local sulong_deps = common.deps.sulong;
packages+: {
gcc: "==6.1.0",
},
downloads+: {
DRAGONEGG_GCC: { name: "gcc+dragonegg", version: "4.6.4-1", platformspecific: true },
DRAGONEGG_LLVM: { name: "clang+llvm", version: "3.2", platformspecific: true },
},
},

# like requireGCC, but only on linux/amd64, ignored otherwise
optionalGCC:: {
packages+: if self.os == "linux" && self.arch == "amd64" then $.requireGCC.packages else {},
downloads+: if self.os == "linux" && self.arch == "amd64" then $.requireGCC.downloads else {},
},

requireGMP:: {
Expand Down
16 changes: 15 additions & 1 deletion sulong/cmake/toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates.
# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -87,3 +87,17 @@ find_tc_ifndef(CMAKE_AR ${SULONG_TOOLCHAIN_BIN}/llvm-ar)
find_tc_ifndef(CMAKE_NM ${SULONG_TOOLCHAIN_BIN}/llvm-nm)

set_ifndef(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-resource-dir
OUTPUT_VARIABLE clang_resource_dir
OUTPUT_STRIP_TRAILING_WHITESPACE)

# convert llvm-dir/lib/clang/18 to just llvm-dir/
get_filename_component(clang_lib_dir ${clang_resource_dir} DIRECTORY)
get_filename_component(clang_lib_dir2 ${clang_lib_dir} DIRECTORY)
get_filename_component(llvm_dir ${clang_lib_dir2} DIRECTORY)

# add file-prefix-map, but not for the "LL" language
# the LL language is used by our test bulid scripts to refer to the llvm-link command, it doesn't understand this option
add_compile_options($<IF:$<COMPILE_LANGUAGE:LL>,,-ffile-prefix-map=${llvm_dir}=LLVM_TOOLCHAIN>)
25 changes: 0 additions & 25 deletions sulong/docs/contributor/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,6 @@ Another useful `mx unittest` flag is `--color`, which makes the output easier to
To attach a debugger to Sulong tests, run `mx` with the `-d` argument, e.g.
`mx -d unittest SulongSuite` or `mx -d gate --tags sulong`.

## Fortran

Some of our tests are Fortran files. Make sure you have GCC, G++, and GFortran
in version 4.5, 4.6 or 4.7 available.

On the Mac you can use Homebrew:

brew tap homebrew/versions
brew install gcc46 --with-fortran
brew link --force gmp4

For the Fortran tests you also need to provide
[DragonEgg](http://dragonegg.llvm.org/) 3.2 and Clang 3.2.

[DragonEgg](http://dragonegg.llvm.org/) is a GCC plugin with which we
can use GCC to compile a source language to LLVM IR. Sulong uses
DragonEgg in its test cases to compile Fortran files to LLVM IR.
Sulong also uses DragonEgg for the C/C++ test cases besides Clang to get
additional "free" test cases for a given C/C++ file. DragonEgg requires
a GCC in the aforementioned versions.

- Sulong expects to find Clang 3.2 in `$DRAGONEGG_LLVM/bin`
- Sulong expects to find GCC 4.5, 4.6 or 4.7 in `$DRAGONEGG_GCC/bin`
- Sulong expects to find `dragonegg.so` under `$DRAGONEGG` or in `$DRAGONEGG_GCC/lib`

## Test Exclusion

Not all tests work under all circumstances. Especially external test suites,
Expand Down
9 changes: 8 additions & 1 deletion sulong/mx.sulong/mx_sulong.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2024, Oracle and/or its affiliates.
# Copyright (c) 2016, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -94,6 +94,13 @@ def _lib_versioned(arg):

mx_subst.results_substitutions.register_with_arg('libv', _lib_versioned)

def sulong_prefix_path(name):
# name is a CMakeNinjaProject with `symlinkSource: True`
# return the path to the build directory, that also includes the sources
p = mx.project(name)
return p.out_dir

mx_subst.results_substitutions.register_with_arg('sulong_prefix', sulong_prefix_path)

def testLLVMImage(image, imageArgs=None, testFilter=None, libPath=True, test=None, unittestArgs=None):
mx_sulong_gate.testLLVMImage(image, imageArgs, testFilter, libPath, test, unittestArgs)
Expand Down
3 changes: 1 addition & 2 deletions sulong/mx.sulong/mx_sulong_gate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2023, Oracle and/or its affiliates.
# Copyright (c) 2016, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -185,7 +185,6 @@ def _unittest(title, test_suite, tags=None, testClasses=None, unittestArgs=None,
_unittest('GCCParserTorture', 'SULONG_PARSER_TORTURE', description="Parser test using GCC suite", testClasses=['ParserTortureSuite'], tags=['parser'])
_unittest('GCC_C', 'SULONG_GCC_C_TEST_SUITE', description="GCC 5.2 test suite (C tests)", testClasses=['GccCSuite'], tags=['gcc_c'])
_unittest('GCC_CPP', 'SULONG_GCC_CPP_TEST_SUITE', description="GCC 5.2 test suite (C++ tests)", testClasses=['GccCppSuite'], tags=['gcc_cpp'])
_unittest('GCC_Fortran', 'SULONG_GCC_FORTRAN_TEST_SUITE', description="GCC 5.2 test suite (Fortran tests)", testClasses=['GccFortranSuite'], tags=['gcc_fortran'])
_unittest('Sulong', 'SULONG_STANDALONE_TEST_SUITES', description="Sulong's internal tests", testClasses='SulongSuite', tags=['sulongStandalone', 'sulongBasic', 'standalone'],
# run only a small subset of the tests on the jvm standalone, the startup overhead per test is too high for more
extraUnittestArgs=['-Dsulongtest.testNameFilter=cpp'] if slowStandalone else [])
Expand Down
67 changes: 1 addition & 66 deletions sulong/mx.sulong/mx_sulong_suite_constituents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2024, Oracle and/or its affiliates.
# Copyright (c) 2016, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -75,60 +75,12 @@ def compileTestSuite(testsuiteproject, extra_build_args):
mx.command_function('build')(defaultBuildArgs + extra_build_args)


class DragonEggSupport:
"""Helpers for DragonEgg

DragonEgg support is controlled by two environment variables:
* `DRAGONEGG_GCC`: path to a GCC installation with dragonegg support
* `DRAGONEGG_LLVM`: path to an LLVM installation that can deal with bitcode produced by DragonEgg
* `DRAGONEGG`: (optional) path to folder that contains the `libdragonegg.so`
"""

@staticmethod
def haveDragonegg():
if not hasattr(DragonEggSupport, '_haveDragonegg'):
DragonEggSupport._haveDragonegg = DragonEggSupport.pluginPath() is not None and os.path.exists(
DragonEggSupport.pluginPath()) and DragonEggSupport.findGCCProgram('gcc', optional=True) is not None
return DragonEggSupport._haveDragonegg

@staticmethod
def pluginPath():
if 'DRAGONEGG' in os.environ:
return os.path.join(os.environ['DRAGONEGG'], mx.add_lib_suffix('dragonegg'))
if 'DRAGONEGG_GCC' in os.environ:
path = os.path.join(os.environ['DRAGONEGG_GCC'], 'lib', mx.add_lib_suffix('dragonegg'))
if os.path.exists(path):
return path
return None

@staticmethod
def findLLVMProgram(program, optional=False):
if 'DRAGONEGG_LLVM' in os.environ:
path = os.environ['DRAGONEGG_LLVM']
return os.path.join(path, 'bin', program)
if optional:
return None
mx.abort("Cannot find LLVM program for dragonegg: {}\nDRAGONEGG_LLVM environment variable not set".format(program))

@staticmethod
def findGCCProgram(gccProgram, optional=False):
if 'DRAGONEGG_GCC' in os.environ:
path = os.environ['DRAGONEGG_GCC']
return os.path.join(path, 'bin', gccProgram)
if optional:
return None
mx.abort("Cannot find GCC program for dragonegg: {}\nDRAGONEGG_GCC environment variable not set".format(gccProgram))


class SulongTestSuiteMixin(object, metaclass=abc.ABCMeta):

def getVariants(self):
if not hasattr(self, '_variants'):
self._variants = []
for v in self.variants:
if 'gcc' in v and not DragonEggSupport.haveDragonegg():
mx.warn('Could not find dragonegg, not building test variant "%s"' % v)
continue
self._variants.append(v)
return self._variants

Expand Down Expand Up @@ -311,14 +263,6 @@ def getBuildEnv(self, replaceVar=mx_subst.path_substitutions):
env['GRAALVM_LLVM_HOME'] = mx_subst.path_substitutions.substitute("<path:SULONG_HOME>")
if 'OS' not in env:
env['OS'] = mx_subst.path_substitutions.substitute("<os>")
if DragonEggSupport.haveDragonegg():
env['DRAGONEGG'] = DragonEggSupport.pluginPath()
env['DRAGONEGG_GCC'] = DragonEggSupport.findGCCProgram('gcc', optional=False)
env['DRAGONEGG_LLVMAS'] = DragonEggSupport.findLLVMProgram("llvm-as")
env['DRAGONEGG_FC'] = DragonEggSupport.findGCCProgram('gfortran', optional=False)
env['FC'] = DragonEggSupport.findGCCProgram('gfortran', optional=False)
elif not self._is_needs_rebuild_call and getattr(self, 'requireDragonegg', False):
mx.abort('Could not find dragonegg, cannot build "{}" (requireDragonegg = True).'.format(self.name))
return env

def getTestFile(self):
Expand Down Expand Up @@ -525,8 +469,6 @@ class SulongCMakeTestSuite(SulongTestSuiteMixin, mx_cmake.CMakeNinjaProject): #
The source file is compiled to an executable with an embedded bitcode section.
- "toolchain"
The toolchain wrappers are used to compile the test source into an executable with embedded bitcode.
- "gcc"
The source is compiled to bitcode using gcc and the DRAGONEGG plugin.
buildRef:
If True (the default), build a reference executable. Setting this to False is useful for embedded tests with
dedicated JUnit test classes.
Expand Down Expand Up @@ -597,13 +539,6 @@ def _default_cmake_vars(self):
_config['LLVM_CONFIG'] = mx_sulong.findBundledLLVMProgram('llvm-config')
_config['LLVM_OBJCOPY'] = mx_sulong.findBundledLLVMProgram('llvm-objcopy')
_config['CMAKE_NM'] = mx_sulong.findBundledLLVMProgram('llvm-nm')
if DragonEggSupport.haveDragonegg():
_config['DRAGONEGG'] = DragonEggSupport.pluginPath()
_config['DRAGONEGG_GCC'] = DragonEggSupport.findGCCProgram('gcc', optional=False)
_config['DRAGONEGG_LLVM_LINK'] = DragonEggSupport.findLLVMProgram("llvm-link")
_config['DRAGONEGG_LLVMAS'] = DragonEggSupport.findLLVMProgram("llvm-as")
_config['DRAGONEGG_FC'] = DragonEggSupport.findGCCProgram('gfortran', optional=False)
_config['FC'] = DragonEggSupport.findGCCProgram('gfortran', optional=False)
return _config

def cmake_config(self):
Expand Down
64 changes: 17 additions & 47 deletions sulong/mx.sulong/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@
},
# Support Libraries.
# Projects depending on these will *not be built* if the 'optional' is 'True' for the given OS/architecture.
# This is a dummy library for dragonegg support.
"DRAGONEGG_SUPPORT" : {
"os_arch" : {
"linux" : {
"amd64" : {
"path": "tests/support.txt",
"digest": "sha512:c02b248975b267f4200603ff2ae40b9d0cdefad4a792f386d610f2b14fb4e67e288c235fd11ed596dd8c91a3dae62fdd741bf97b5c01b5f085485f221702f0a1",
},
"<others>": {"optional": True},
},
"<others>": {"<others>" : {"optional": True}},
},
},
# This is a dummy library for malloc.h support.
"MALLOC_H_SUPPORT" : {
"os_arch" : {
Expand Down Expand Up @@ -963,6 +950,7 @@
"LIBCXX_INCLUDE_BENCHMARKS": "NO",
"LIBCXX_INCLUDE_TESTS": "NO",
"LIBCXX_ENABLE_STATIC" : "NO",
"LIBUNWIND_ENABLE_STATIC" : "NO",
"CMAKE_INSTALL_PREFIX" : "native",
# workaround for build problem with cmake >=3.22
# see https://lists.llvm.org/pipermail/llvm-dev/2021-December/154144.html
Expand All @@ -978,6 +966,9 @@
"cmakeConfig" : {
"CMAKE_INSTALL_RPATH" : "\\$ORIGIN",
"LLVM_ENABLE_RUNTIMES" : "libcxx;libcxxabi;libunwind",
"CMAKE_ASM_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_C_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_CXX_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
},
},
"linux-musl" : {
Expand All @@ -988,6 +979,9 @@
"CMAKE_INSTALL_RPATH" : "\\$ORIGIN",
"LLVM_ENABLE_RUNTIMES" : "libcxx;libcxxabi;libunwind",
"LIBCXX_HAS_MUSL_LIBC" : "YES",
"CMAKE_ASM_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_C_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_CXX_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
},
},
"darwin" : {
Expand All @@ -998,6 +992,9 @@
"CMAKE_INSTALL_RPATH" : "@loader_path/",
"LLVM_ENABLE_RUNTIMES" : "libcxx;libcxxabi;libunwind",
"CMAKE_LIBTOOL" : "<path:LLVM_TOOLCHAIN>/bin/llvm-libtool-darwin",
"CMAKE_ASM_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_C_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
"CMAKE_CXX_FLAGS": "-ffile-prefix-map=<sulong_prefix:com.oracle.truffle.llvm.libraries.bitcode.libcxx>=llvm-project",
},
},
"windows" : {
Expand Down Expand Up @@ -1109,7 +1106,7 @@
"com.oracle.truffle.llvm.tests.sulong.native" : {
"subDir" : "tests",
"class" : "SulongCMakeTestSuite",
"variants" : ["bitcode-O0", "bitcode-O1", "bitcode-O2", "bitcode-O3", "gcc-O0"],
"variants" : ["bitcode-O0", "bitcode-O1", "bitcode-O2", "bitcode-O3"],
"dependencies" : ["SULONG_TEST"],
"testProject" : True,
"defaultBuild" : False,
Expand Down Expand Up @@ -1524,28 +1521,6 @@
"testProject" : True,
"defaultBuild" : False,
},
"gcc_fortran" : {
"subDir" : "tests/gcc",
# The Ninja generator used by mx (version 1.8.2) does not support Fortran using Ninja version [GR-30808]
# "class" : "ExternalCMakeTestSuite",
# "variants" : ["executable-O0"],
"class" : "ExternalTestSuite",
"variants" : ["O0_OUT"],
"testDir" : "gcc-5.2.0/gcc/testsuite",
"fileExts" : [".f90", ".f", ".f03"],
"requireDragonegg" : True,
"native" : True,
"vpath" : True,
"single_job" : True, # problem with parallel builds and temporary module files
"buildRef" : True,
"dependencies" : ["SULONG_TEST"],
"buildDependencies" : [
"GCC_SOURCE",
"DRAGONEGG_SUPPORT",
],
"testProject" : True,
"defaultBuild" : False,
},
"parserTorture" : {
"subDir" : "tests/gcc",
"class" : "ExternalCMakeTestSuite",
Expand Down Expand Up @@ -1896,7 +1871,12 @@
},
"<others>" : {
"layout" : {
"./": ["dependency:com.oracle.truffle.llvm.libraries.bitcode.libcxx/*"],
"./": [{
"source_type": "dependency",
"dependency": "com.oracle.truffle.llvm.libraries.bitcode.libcxx",
"path": "*",
"exclude": "native/lib/*.a",
}],
"./native/lib/<lib:graalvm-llvm>": "link:<libv:graalvm-llvm.1>",
# for source compatibility
"./native/lib/<lib:polyglot-mock>": "link:<lib:graalvm-llvm>",
Expand Down Expand Up @@ -2256,16 +2236,6 @@
"testDistribution" : True,
"defaultBuild" : False,
},
"SULONG_GCC_FORTRAN_TEST_SUITE" : {
"native" : True,
"relpath" : True,
"platformDependent" : True,
"layout" : {
"./" : ["dependency:gcc_fortran/*"],
},
"testDistribution" : True,
"defaultBuild" : False,
},
"SULONG_PARSER_TORTURE" : {
"native" : True,
"relpath" : True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021, 2024, Oracle and/or its affiliates.
# Copyright (c) 2021, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -53,8 +53,11 @@ check_var(GRAALVM_LLVM_LIBS_INCLUDE_DIR)
check_var(LIBCXX_SRC)

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
add_compile_options(-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-fdebug-prefix-map=${CMAKE_BINARY_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${CMAKE_BINARY_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${GRAALVM_LLVM_INCLUDE_DIR}=com.oracle.truffle.llvm.libraries.graalvm.llvm/include)
add_compile_options(-ffile-prefix-map=${GRAALVM_LLVM_LIBS_INCLUDE_DIR}=com.oracle.truffle.llvm.libraries.graalvm.llvm.libs/include)
add_compile_options(-ffile-prefix-map=${LIBCXX_SRC}=llvm-project)

if (APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021, 2022, Oracle and/or its affiliates.
# Copyright (c) 2021, 2025, Oracle and/or its affiliates.
#
# All rights reserved.
#
Expand Down Expand Up @@ -37,8 +37,9 @@ if(NOT GRAALVM_LLVM_INCLUDE_DIR)
endif()

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
add_compile_options(-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-fdebug-prefix-map=${CMAKE_BINARY_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${CMAKE_BINARY_DIR}=${CMAKE_PROJECT_NAME})
add_compile_options(-ffile-prefix-map=${GRAALVM_LLVM_INCLUDE_DIR}=com.oracle.truffle.llvm.libraries.graalvm.llvm/include)

if (APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path")
Expand Down
Loading
Loading