Skip to content
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

[WIP] Adding ROOT_jll #9300

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
194 changes: 194 additions & 0 deletions R/ROOT/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "ROOT"
version = v"6.32.2"

# Collection of sources required to complete build
sources = [
ArchiveSource("https://root.cern/download/root_v6.32.02.source.tar.gz", "3d0f76bf05857e1807ccfb2c9e014f525bcb625f94a2370b455f4b164961602d"),
DirectorySource("./bundled")
]

# Bash recipe for building across all platforms
script = raw"""

cd $WORKSPACE
install_license srcdir/root-*/LICENSE

# Release type and C++ standard
CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=Release)
CMAKE_FLAGS+=(-DCMAKE_CXX_STANDARD=17)

# ROOT options to enable/disable
CMAKE_FLAGS+=(-Dgnuinstall=OFF)
CMAKE_FLAGS+=(-Drpath=ON)
CMAKE_FLAGS+=(-Dshared=ON)
CMAKE_FLAGS+=(-Dsoversion=OFF)
CMAKE_FLAGS+=(-Dfail-on-missing=ON)
CMAKE_FLAFS+=(-Dbuiltin_afterimage=ON)
CMAKE_FLAGS+=(-Druntime_cxxmodules=OFF)

# LLVM tries to run a bunch of configure tests. Tell it what the output would have been.
CMAKE_FLAGS+=(-Dfound_urandom_EXITCODE=0)
CMAKE_FLAGS+=(-Dfound_urandom_EXITCODE__TRYRUN_OUTPUT='')

export SYSTEM_INCLUDE_PATH="`$MACHTYPE-g++ --sysroot="/opt/$MACHTYPE/$MACHTYPE/sys-root" -E -x c++ -v /dev/null 2>&1 | awk '{gsub("^ ", "")} /End of search list/{a=0} {if(a==1){s=s d \$0;d=":"}} /#include <...> search starts here/{a=1} END{print s}'`"
export CPLUS_INCLUDE_PATH=$SYSTEM_INCLUDE_PATH # Needed for the native build (musl)

#---Build host native rootcling, llvm-tblgen, clang-tblgen for cross-compilation------------------------
if [ $target != $MACHTYPE ]; then
# Patch the sources to use the native binary for rootcling
(cd srcdir/root-*/
atomic_patch -p2 ../patches/rootcling-cross-compile.patch
)
# host $sysroot/local should point to $host_prefix (issue BinaryBuilder)
rm /opt/$MACHTYPE/$MACHTYPE/sys-root/usr/local
ln -s $host_prefix /opt/$MACHTYPE/$MACHTYPE/sys-root/usr/local

# Build for the host binary native used in second step build process
mkdir native
cmake -GNinja -DCMAKE_INSTALL_PREFIX=$prefix \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_HOST_TOOLCHAIN} \
-DLLVM_HOST_TRIPLE=$MACHTYPE \
-DLLVM_TARGET_TRIPLE=$target \
-Dminimal=ON \
${CMAKE_FLAGS[@]} \
-B native -S srcdir/root-*/
ninja -C native -j${nproc} rootcling_stage1 rootcling llvm-tblgen clang-tblgen llvm-config llvm-symbolizer

# Add extra options to use the built native binaries
CMAKE_EXTRA_OPTS+=(-DNATIVE_BINARY_DIR=$PWD/native)
CMAKE_EXTRA_OPTS+=(-DLLVM_TABLEGEN_EXE=$PWD/native/interpreter/llvm-project/llvm/bin/llvm-tblgen)
CMAKE_EXTRA_OPTS+=(-DCLANG_TABLEGEN_EXE=$PWD/native/interpreter/llvm-project/llvm/bin/clang-tblgen)
CMAKE_EXTRA_OPTS+=(-DLLVM_CONFIG_PATH=$PWD/native/interpreter/llvm-project/llvm/bin/llvm-config)

# Define ROOTCLINGNATIVE to use the native rootcling
export ROOTCLINGNATIVE="env CPLUS_INCLUDE_PATH=${SYSTEM_INCLUDE_PATH} $PWD/native/bin/rootcling"

# Remove the CPLUS_INCLUDE_PATH environment variable. Was needed for the native build only
unset CPLUS_INCLUDE_PATH
fi

#---Standard build (cross-compilation)-------------------------------------------------------------
mkdir build
cmake -GNinja \
-DCMAKE_INSTALL_PREFIX=$prefix \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
${CMAKE_FLAGS[@]} \
-Dgminimal=ON \
${CMAKE_EXTRA_OPTS[@]} \
-B build -S srcdir/root-*/
ninja -C build -j${nproc} install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = [
Platform("x86_64", "linux"; libc = "glibc"),
Platform("x86_64", "linux"; libc = "musl"),
# Platform("aarch64", "linux"; libc = "glibc"),
# Platform("armv6l", "linux", libc = "glibc"),
# Platform("armv7l", "linux", libc = "glibc"),
# Platform("powerpc64le", "linux"; libc = "glibc"),
Platform("aarch64", "macos"),
# Platform("x86_64", "macos"),
] |> expand_cxxstring_abis

# The products that we will ensure are always built
products = [
ExecutableProduct("root", :root),
LibraryProduct("libCling", :libCling; dont_dlopen=true),
LibraryProduct("libCore", :libCore; dont_dlopen=true),
LibraryProduct("libEG", :libEG; dont_dlopen=true),
LibraryProduct("libFitPanel", :libFitPanel; dont_dlopen=true),
LibraryProduct("libFoam", :libFoam; dont_dlopen=true),
LibraryProduct("libFumili", :libFumili; dont_dlopen=true),
LibraryProduct("libGed", :libGed; dont_dlopen=true),
LibraryProduct("libGenVector", :libGenVector; dont_dlopen=true),
LibraryProduct("libGeomBuilder", :libGeomBuilder; dont_dlopen=true),
LibraryProduct("libGeomPainter", :libGeomPainter; dont_dlopen=true),
LibraryProduct("libGeom", :libGeom; dont_dlopen=true),
LibraryProduct("libGpad", :libGpad; dont_dlopen=true),
LibraryProduct("libGraf3d", :libGraf3d; dont_dlopen=true),
LibraryProduct("libGraf", :libGraf; dont_dlopen=true),
LibraryProduct("libGuiBld", :libGuiBld; dont_dlopen=true),
LibraryProduct("libGuiHtml", :libGuiHtml; dont_dlopen=true),
LibraryProduct("libGui", :libGui; dont_dlopen=true),
LibraryProduct("libGX11", :libGX11; dont_dlopen=true),
LibraryProduct("libGX11TTF", :libGX11TTF; dont_dlopen=true),
LibraryProduct("libHistPainter", :libHistPainter; dont_dlopen=true),
LibraryProduct("libHist", :libHist; dont_dlopen=true),
LibraryProduct("libHtml", :libHtml; dont_dlopen=true),
LibraryProduct("libImt", :libImt; dont_dlopen=true),
LibraryProduct("libMathCore", :libMathCore; dont_dlopen=true),
LibraryProduct("libMatrix", :libMatrix; dont_dlopen=true),
LibraryProduct("libMinuit2", :libMinuit2; dont_dlopen=true),
LibraryProduct("libMinuit", :libMinuit; dont_dlopen=true),
LibraryProduct("libMLP", :libMLP; dont_dlopen=true),
LibraryProduct("libMultiProc", :libMultiProc; dont_dlopen=true),
LibraryProduct("libNet", :libNet; dont_dlopen=true),
LibraryProduct("libNew", :libNew; dont_dlopen=true),
LibraryProduct("libPhysics", :libPhysics; dont_dlopen=true),
LibraryProduct("libPostscript", :libPostscript; dont_dlopen=true),
LibraryProduct("libQuadp", :libQuadp; dont_dlopen=true),
LibraryProduct("libRCsg", :libRCsg; dont_dlopen=true),
LibraryProduct("libRecorder", :libRecorder; dont_dlopen=true),
LibraryProduct("libRint", :libRint; dont_dlopen=true),
LibraryProduct("libRIO", :libRIO; dont_dlopen=true),
LibraryProduct("libRootAuth", :libRootAuth; dont_dlopen=true),
LibraryProduct("libROOTVecOps", :libROOTVecOps; dont_dlopen=true),
LibraryProduct("libSmatrix", :libSmatrix; dont_dlopen=true),
LibraryProduct("libSPlot", :libSPlot; dont_dlopen=true),
LibraryProduct("libSQLIO", :libSQLIO; dont_dlopen=true),
LibraryProduct("libThread", :libThread; dont_dlopen=true),
LibraryProduct("libTreePlayer", :libTreePlayer; dont_dlopen=true),
LibraryProduct("libTree", :libTree; dont_dlopen=true),
LibraryProduct("libTreeViewer", :libTreeViewer; dont_dlopen=true),
LibraryProduct("libX3d", :libX3d; dont_dlopen=true),
LibraryProduct("libXMLIO", :libXMLIO; dont_dlopen=true)
]

# Some dependencies are needed only on Linux and FreeBSD
x11_platforms = filter(p ->Sys.islinux(p) || Sys.isfreebsd(p), platforms)

# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("Xorg_xorgproto_jll"; platforms=x11_platforms)
HostBuildDependency("Zlib_jll")
HostBuildDependency("Zstd_jll")
HostBuildDependency("Lz4_jll")
HostBuildDependency("nlohmann_json_jll")
HostBuildDependency("FreeType2_jll")
HostBuildDependency("PCRE_jll")
HostBuildDependency("XZ_jll")
HostBuildDependency("xxHash_jll")
Dependency("Zlib_jll")
Dependency("Zstd_jll")
Dependency("Lz4_jll")
Dependency("nlohmann_json_jll")
Dependency("FreeType2_jll")
Dependency("PCRE_jll")
Dependency("XZ_jll")
Dependency("xxHash_jll")
Dependency("OpenSSL_jll"; compat="1.1.10")
Dependency("Xorg_libX11_jll"; platforms=x11_platforms)
Dependency("Xorg_libXpm_jll"; platforms=x11_platforms)
Dependency("Xorg_libXft_jll"; platforms=x11_platforms)
Dependency("Xorg_libICE_jll"; platforms=x11_platforms)
Dependency("Xorg_libSM_jll"; platforms=x11_platforms)
Dependency("Xorg_libXfixes_jll"; platforms=x11_platforms)
Dependency("Xorg_libXi_jll"; platforms=x11_platforms)
Dependency("Xorg_libXinerama_jll"; platforms=x11_platforms)
Dependency("Xorg_libXmu_jll"; platforms=x11_platforms)
Dependency("Xorg_libXt_jll"; platforms=x11_platforms)
Dependency("Xorg_libXtst_jll"; platforms=x11_platforms)
Dependency("Xorg_xcb_util_jll"; platforms=x11_platforms)
Dependency("Xorg_libxkbfile_jll"; platforms=x11_platforms)
#Dependency("libLVM_jll")
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
preferred_gcc_version=v"11", julia_compat="1.6")
182 changes: 182 additions & 0 deletions R/ROOT/bundled/patches/rootcling-cross-compile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
--- a/root/cmake/modules/RootMacros.cmake 2024-01-31 09:17:06.000000000 +0100
+++ c/root/cmake/modules/RootMacros.cmake 2024-06-29 18:12:28.081464326 +0200
@@ -8,6 +8,8 @@
# RootMacros.cmake
#---------------------------------------------------------------------------------------------------

+set(NATIVE_BINARY_DIR FALSE CACHE FILEPATH "Path of native built in case of cross compiling.")
+
if(WIN32)
set(libprefix lib)
set(ld_library_path PATH)
@@ -603,20 +605,37 @@
#---what rootcling command to use--------------------------
if(ARG_STAGE1)
if(MSVC AND CMAKE_ROOTTEST_DICT)
- set(command ${CMAKE_COMMAND} -E ${CMAKE_BINARY_DIR}/bin/rootcling_stage1.exe)
+ if(NATIVE_BINARY_DIR)
+ set(command ${CMAKE_COMMAND} -E ${NATIVE_BINARY_DIR}/bin/rootcling_stage1.exe)
+ else()
+ set(command ${CMAKE_COMMAND} -E ${CMAKE_BINARY_DIR}/bin/rootcling_stage1.exe)
+ endif()
else()
- set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" $<TARGET_FILE:rootcling_stage1>)
+ if(NATIVE_BINARY_DIR)
+ set(command ${CMAKE_COMMAND} -E env "CPLUS_INCLUDE_PATH=$ENV{SYSTEM_INCLUDE_PATH}" "LD_LIBRARY_PATH=${NATIVE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${NATIVE_BINARY_DIR}/core/rootcling_stage1/src/rootcling_stage1)
+ else()
+ set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" $<TARGET_FILE:rootcling_stage1>)
+ endif()
endif()
set(ROOTCINTDEP rconfigure)
set(pcm_name)
else()
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(MSVC AND CMAKE_ROOTTEST_DICT)
- set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe)
+ if(NATIVE_BINARY_DIR)
+ set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${NATIVE_BINARY_DIR}/bin/rootcling.exe)
+ else()
+ set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/core/rootcling_stage1/src/rootcling.exe)
+ endif()
else()
- set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}"
- "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
- # Modules need RConfigure.h copied into include/.
+ if(NATIVE_BINARY_DIR)
+ set(command ${CMAKE_COMMAND} -E env "CPLUS_INCLUDE_PATH=$ENV{SYSTEM_INCLUDE_PATH}" "LD_LIBRARY_PATH=${NATIVE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}"
+ "ROOTIGNOREPREFIX=1" ${NATIVE_BINARY_DIR}/bin/rootcling -rootbuild)
+ else()
+ set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}"
+ "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
+ endif()
+ # Modules need RConfigure.h copied into include/.
set(ROOTCINTDEP rootcling rconfigure)
endif()
elseif(TARGET ROOT::rootcling)

--- a/root/CMakeLists.txt
+++ b/root/CMakeLists.txt
@@ -601,24 +601,26 @@ if(runtime_cxxmodules)
endif()

#---hsimple.root---------(use the executable for clearer dependencies and proper return code)---
-add_custom_target(hsimple ALL DEPENDS tutorials/hsimple.root)
-add_dependencies(hsimple onepcm)
-if(WIN32)
- add_custom_command(OUTPUT tutorials/hsimple.root
- COMMAND set PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} &&
- set ROOTIGNOREPREFIX=1 && set ROOT_HIST=0 &&
- $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
- WORKING_DIRECTORY tutorials
- DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
-else()
- add_custom_command(OUTPUT tutorials/hsimple.root
- COMMAND ${MODULES_ROOT_INCPATH} ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
- ROOTIGNOREPREFIX=1 ROOT_HIST=0
- $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
- WORKING_DIRECTORY tutorials
- DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
+if(NOT CMAKE_CROSSCOMPILING)
+ add_custom_target(hsimple ALL DEPENDS tutorials/hsimple.root)
+ add_dependencies(hsimple onepcm)
+ if(WIN32)
+ add_custom_command(OUTPUT tutorials/hsimple.root
+ COMMAND set PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} &&
+ set ROOTIGNOREPREFIX=1 && set ROOT_HIST=0 &&
+ $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
+ WORKING_DIRECTORY tutorials
+ DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
+ else()
+ add_custom_command(OUTPUT tutorials/hsimple.root
+ COMMAND ${MODULES_ROOT_INCPATH} ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
+ ROOTIGNOREPREFIX=1 ROOT_HIST=0
+ $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
+ WORKING_DIRECTORY tutorials
+ DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
+ endif()
+ install(FILES ${CMAKE_BINARY_DIR}/tutorials/hsimple.root DESTINATION ${CMAKE_INSTALL_TUTDIR} COMPONENT tests)
endif()
-install(FILES ${CMAKE_BINARY_DIR}/tutorials/hsimple.root DESTINATION ${CMAKE_INSTALL_TUTDIR} COMPONENT tests)

if(runtime_cxxmodules)
add_dependencies(hsimple modules_idx)
@@ -805,4 +807,6 @@ Linker flags:
ROOT_SHOW_ENABLED_OPTIONS()

#---Packaging-------------------------------------------------------------------------------------
-include(RootCPack)
+if(NOT CMAKE_CROSSCOMPILING)
+ include(RootCPack)
+endif()
--- a/root/cmake/modules/SetUpMacOS.cmake
+++ b/root/cmake/modules/SetUpMacOS.cmake
@@ -113,15 +113,14 @@ endif()

#---Avoid using a x86_64 Ninja executable with on a arm64 MacOS
#---This issue leads to the external being build for x86_64 instead of arm64
-execute_process(COMMAND lipo -archs ${CMAKE_MAKE_PROGRAM} OUTPUT_VARIABLE _NINJA_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(CMAKE_GENERATOR MATCHES Ninja)
-
- set( _NINJA_ARCH_LIST ${_NINJA_ARCH} )
- separate_arguments(_NINJA_ARCH_LIST) # This replace space with semi-colons
- if (NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" IN_LIST _NINJA_ARCH_LIST)
- message(FATAL_ERROR
- " ${CMAKE_MAKE_PROGRAM} does not support ${CMAKE_HOST_SYSTEM_PROCESSOR}.\n"
- " It only supports ${_NINJA_ARCH_LIST}.\n"
- " Downloading the latest version of Ninja might solve the problem.\n")
- endif()
-endif()
+#execute_process(COMMAND lipo -archs ${CMAKE_MAKE_PROGRAM} OUTPUT_VARIABLE _NINJA_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
+#if(CMAKE_GENERATOR MATCHES Ninja)
+# set( _NINJA_ARCH_LIST ${_NINJA_ARCH} )
+# separate_arguments(_NINJA_ARCH_LIST) # This replace space with semi-colons
+# if (NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" IN_LIST _NINJA_ARCH_LIST)
+# message(FATAL_ERROR
+# " ${CMAKE_MAKE_PROGRAM} does not support ${CMAKE_HOST_SYSTEM_PROCESSOR}.\n"
+# " It only supports ${_NINJA_ARCH_LIST}.\n"
+# " Downloading the latest version of Ninja might solve the problem.\n")
+# endif()
+#endif()
--- a/root/cmake/modules/SearchInstalledSoftware.cmake
+++ b/root/cmake/modules/SearchInstalledSoftware.cmake
@@ -37,7 +37,9 @@ endif()
if(cocoa)
if(APPLE)
set(x11 OFF CACHE BOOL "Disabled because cocoa requested (${x11_description})" FORCE)
- set(builtin_freetype ON CACHE BOOL "Enabled because needed for Cocoa graphics (${builtin_freetype_description})" FORCE)
+ if(NOT CMAKE_CROSSCOMPILING) # leave freetype as external on cross-compiling
+ set(builtin_freetype ON CACHE BOOL "Enabled because needed for Cocoa graphics (${builtin_freetype_description})" FORCE)
+ endif()
else()
message(STATUS "Cocoa option can only be enabled on MacOSX platform")
set(cocoa OFF CACHE BOOL "Disabled because only available on MacOSX (${cocoa_description})" FORCE)
--- a/root/etc/dictpch/makepch.py
+++ b/root/etc/dictpch/makepch.py
@@ -99,7 +99,12 @@ def makepch():
allheadersFilename.replace("\\","/")
alllinkdefsFilename.replace("\\","/")

- rootclingExe = os.path.join(rootdir,"bin","rootcling")
+ if "ROOTCLINGNATIVE" in os.environ:
+ rootclingExe = os.environ["ROOTCLINGNATIVE"]
+ crosscomp = True
+ else:
+ rootclingExe = os.path.join(rootdir,"bin","rootcling")
+ crosscomp = False
command = "%s %s -generate-pch -f allDict.cxx -noDictSelection %s %s %s %s" %(rootclingExe,
rootbuildFlag,
allCppFlags,
@@ -111,9 +116,10 @@ def makepch():
print(command)

my_env = os.environ.copy()
- existing_ldlib = my_env.get("LD_LIBRARY_PATH")
- if not existing_ldlib: existing_ldlib = ""
- my_env["LD_LIBRARY_PATH"] = os.path.join(rootdir, "lib") + ":" + existing_ldlib
+ if not crosscomp:
+ existing_ldlib = my_env.get("LD_LIBRARY_PATH")
+ if not existing_ldlib: existing_ldlib = ""
+ my_env["LD_LIBRARY_PATH"] = os.path.join(rootdir, "lib") + ":" + existing_ldlib

ret = subprocess.call(command.split(), env=my_env)
if ret == 0: