Skip to content

Commit 6c3e85c

Browse files
committed
Fix for macOS and CI improvements
CI: - add julia package cache in CI (julia-ations/cache) - add cache of ROOT install for test-macos - activate annotate option of julia-runtests: "create GitHub annotations to show test failures inlines" - add julia version '1' (latest release) in the matrix - add macos x86 in the matrix - cleanup: removed commented line of LFFLAGS, CPPFLAGS. etc. environment variable setttings - fix CI to get logs displayed during compilation of wrapper library in the macOS test. Fix compilation of wrapper for macos: - set flag to disable std::ranges if used libcxxwrap_julia_stl library was built with an old c++ library missing it. - remove ROOT!AddClass(...) wrappers that triggers a link error on ARM64 (tested with macOS) Wrapper compilation performance: - Add header precompilation. Add the "no_auto_compile" ROOT package preference to allow disabling wrapper library build on package import (used in macos test CI). Code generated with ROOT.jl-generator commit 8aca08bfa1abc635adf866c31d018d7d8d69f575
1 parent 56147f2 commit 6c3e85c

File tree

11 files changed

+93
-34
lines changed

11 files changed

+93
-34
lines changed

.github/workflows/test-linux.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
defaults:
99
run:
10-
shell: bash
10+
shell: bash -l {0}
1111

1212
jobs:
1313
test:
@@ -18,6 +18,7 @@ jobs:
1818
matrix:
1919
version:
2020
- '1.10'
21+
- '1'
2122
os:
2223
- ubuntu-latest
2324
# - macOS-latest
@@ -31,5 +32,9 @@ jobs:
3132
with:
3233
version: ${{ matrix.version }}
3334
arch: ${{ matrix.arch }}
34-
- uses: julia-actions/julia-buildpkg@latest
35-
- uses: julia-actions/julia-runtest@latest
35+
- uses: julia-actions/cache@v2
36+
#- uses: julia-actions/julia-buildpkg@latest
37+
- name: Run package tests
38+
uses: julia-actions/julia-runtest@latest
39+
with:
40+
annotate: true

.github/workflows/test-macos.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ jobs:
1818
matrix:
1919
version:
2020
- '1.10'
21+
- '1'
2122
os:
2223
# - ubuntu-latest
2324
- macOS-latest
2425
arch:
2526
- aarch64
27+
- x64
2628
steps:
2729
- uses: actions/checkout@v3
2830
with:
@@ -31,27 +33,33 @@ jobs:
3133
with:
3234
version: ${{ matrix.version }}
3335
arch: ${{ matrix.arch }}
36+
- uses: julia-actions/cache@v2
37+
- name: Cache ROOT install
38+
id: cache-root-install
39+
uses: actions/cache@v5
40+
with:
41+
path: conda_for_rootjl
42+
key: ${{ runner.os }}-${{ matrix.arch }}-root-${{ hashFiles('.github/workflows/install_root_with_conda.sh')}}
3443
- name: Install ROOT
44+
if: steps.cache-root-install.outputs.cache-hit != 'true'
3545
run: |
3646
CONDA_BINDIR="`sh .github/workflows/install_root_with_conda.sh | tail -n 1`"
3747
source "$CONDA_BINDIR/activate"
3848
cat >> "$GITHUB_ENV" <<EOF
39-
#LDFLAGS="$LDFLAGS"
40-
#CPPFLAGS="$CPPFLAGS"
41-
#LIBTOOL="$LIBTOOL"
42-
#CXXFLAGS="$CXXFLAGS"
43-
#CPP="$CPP"
4449
PATH="$PATH"
45-
#LD="$LD"
4650
CXX="$CXX"
47-
#CFLAGS="$CFLAGS"
48-
#CC="$CC"
4951
EOF
5052
echo -n "ROOT binary: " 1>&2
5153
which root 1>&2
5254
- name: Build the Julia wrapper library
5355
run: |
54-
julia --project=@. -e 'import Pkg; Pkg.add("ROOTprefs"); using ROOTprefs; set_use_root_jll(false); set_ROOTSYS()' 1>&2
56+
cd ..
57+
#for some reason in auto-compile mode, the compilation logs are not displayed when run in the CI. Use explicit compile call.
58+
julia --project=@. -e 'import Pkg; Pkg.add("ROOTprefs"); using ROOTprefs; ROOTprefs._set_preference("no_auto_compile", true); Pkg.add(path="./ROOT.jl"); import ROOT; ROOT.cxxcompile();' 1>&2
59+
#trigger package precompilation
5560
julia --project=@. -e 'import ROOT' 1>&2
5661
#- uses: julia-actions/julia-buildpkg@latest
57-
- uses: julia-actions/julia-runtest@latest
62+
- name: Run package tests
63+
uses: julia-actions/julia-runtest@latest
64+
with:
65+
annotate: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ test/test1.root
2121
test/test2.root
2222
test/test3.root
2323
LocalPreferences.toml
24+
local

deps/Makefile

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ UNAME=$(shell uname)
99
ROOT_LIBS = $(shell $(ROOT_CONFIG) --libs) -lGeom
1010
ROOT_INC_DIR = $(shell $(ROOT_CONFIG) --incdir)
1111

12+
JULIA = julia
13+
1214
CPPFLAGS = -MMD -I. -I $(CXXWRAP_PREFIX)/include
15+
#JCXX_HAS_RANGE must be set to 0 if libcxxwrap_julia_stl.so was compiled without std::ranges support
16+
#JLCXX_HAS_RANGE = isdefined(CxxWrap.StdLib, :HAS_RANGES) ? 1 : 0
17+
#Disable dependencies on std::ranges if libcxxwrap_julis_stl.so was compiled without it
18+
ifeq ($(JLCXX_HAS_RANGES), 0)
19+
CPPFLAGS += -DJLCXX_FORCE_RANGES_OFF
20+
endif
1321
CXXFLAGS = $(patsubst -std=gnu%,,$(shell $(JL_SHARE)/julia-config.jl --cflags))
1422
CXXFLAGS += $(shell $(ROOT_CONFIG) --cflags)
1523
CXXFLAGS += -I$(VDT_DIR)/include
@@ -19,7 +27,6 @@ CXXFLAGS += -Wno-c++20-extensions
1927
#CXXFLAGS += -Wall -O0 -g #To compile with debugger infomation
2028
LDFLAGS = $(shell $(JL_SHARE)/julia-config.jl --ldflags)
2129
LDLIBS = $(shell $(JL_SHARE)/julia-config.jl --ldlibs) -L$(CXXWRAP_PREFIX)/lib -lcxxwrap_julia -lcxxwrap_julia_stl
22-
JULIA = julia
2330

2431
CXX_IS_CLANG = $(shell $(CXX) -dM -E - < /dev/null | grep -c __clang__)
2532

@@ -39,8 +46,10 @@ endif
3946

4047
ifneq ($(CXX_IS_CLANG), 0)
4148
CXXFLAGS += -ferror-limit=3
49+
PCH_SUFFIX=.pch
4250
else #assuming gcc
4351
CXXFLAGS += -fmax-errors=3
52+
PCH_SUFFIX=.gch
4453
endif
4554

4655

@@ -94,17 +103,30 @@ JULIA_LOAD_PATH=`pwd`/build/ROOT/src:$(JULIA_LOAD_PATH): "$(JULIA)" --project=..
94103
JULIA_LOAD_PATH=`pwd`/build/ROOT/src:$(JULIA_LOAD_PATH): "$(JULIA)" --project=.. TTree_examples/write_tree3.jl \
95104
&& JULIA_LOAD_PATH=`pwd`/build/ROOT/src:$(JULIA_LOAD_PATH): "$(JULIA)" --project=.. TTree_examples/read_tree3.jl
96105

97-
$(BUILD_DIR)/%.o: src/%.cxx
106+
#$(BUILD_DIR)/pch.h:
107+
# $(Q) [ -d $(BUILD_DIR)/libROOT/build ] || mkdir -p $(BUILD_DIR)/libROOT/build
108+
# echo '#include "Wrapper.h"\n#include "jlROOT.h"\n#include "jlcxx/functions.hpp"\n#include "jlcxx/stl.hpp"\n' > $@
109+
#
110+
#$(BUILD_DIR)/%.h$(PCH_SUFFIX): $(BUILD_DIR)/%.h
111+
# @echo "Precompile the header files."
112+
# $(Q) $(COMPILE.cc) $(CPPFLAGS) -I src -x c++-header -o $@ $<
113+
114+
$(BUILD_DIR)/pch.h$(PCH_SUFFIX):
115+
@echo "Precompile the header files."
116+
$(Q) [ -d $(BUILD_DIR)/include ] || mkdir -p $(BUILD_DIR)/include
117+
$(Q)echo '#include "Wrapper.h"\n#include "jlROOT.h"\n#include "jlcxx/functions.hpp"\n#include "jlcxx/stl.hpp"\n' > $(BUILD_DIR)/include/pch.h
118+
$(Q) $(COMPILE.cc) -Isrc -x c++-header -o $@ $(BUILD_DIR)/include/pch.h
119+
120+
$(BUILD_DIR)/%.o: src/%.cxx $(BUILD_DIR)/pch.h$(PCH_SUFFIX)
98121
@echo "Make $(notdir $@)"
99-
$(Q) [ -d $(BUILD_DIR)/libROOT/build ] || mkdir -p $(BUILD_DIR)/libROOT/build
100-
$(Q) $(COMPILE.cc) $(CPPFLAGS) -o $@ $<
122+
$(Q) [ -d $(BUILD_DIR) ] || mkdir -p $(BUILD_DIR)
123+
$(Q) $(COMPILE.cc) -include $(BUILD_DIR)/pch.h -o $@ $<
101124

102125
$(BUILD_DIR)/libroot_julia$(SO_SUFFIX): $(OBJS)
103126
@echo "Make $(notdir $@)"
104127
$(Q) $(MAKE) check_root
105128
$(Q) $(LINK.o) -o $@ --shared -fPIC $(OBJS) $(ROOT_LIBS) $(LDLIBS)
106129

107-
108130
echo_%:
109131
@echo "$* = $(subst ",\",$($*))"
110132

deps/pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "Failed to use precompile headers."

deps/src/JlGlobals.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ struct JlGlobal: public Wrapper {
2020
// defined in /home/pgras/.julia/artifacts/541477a5cefd778e4ecbd314cfbc99eed20f2c4c/include/Rtypes.h:120:19
2121
t.method("ROOT!CreateClass", [](const char * arg0, int16_t arg1, const std::type_info & arg2, TVirtualIsAProxy * arg3, const char * arg4, const char * arg5, int32_t arg6, int32_t arg7)->TClass * { return ROOT::CreateClass(arg0, (Version_t)arg1, arg2, arg3, arg4, arg5, (Int_t)arg6, (Int_t)arg7); }, jlcxx::arg("this"), jlcxx::arg("cname"), jlcxx::arg("id"), jlcxx::arg("info"), jlcxx::arg("isa"), jlcxx::arg("dfil"), jlcxx::arg("ifil"), jlcxx::arg("dl"), jlcxx::arg("il"));
2222

23+
/* Link fails on ARM64
2324
DEBUG_MSG("Adding wrapper for void ::ROOT::AddClass(const char *, Version_t, const std::type_info &, DictFuncPtr_t, Int_t) (" __HERE__ ")");
2425
// signature to use in the veto list: void ::ROOT::AddClass(const char *, Version_t, const std::type_info &, DictFuncPtr_t, Int_t)
2526
// defined in /home/pgras/.julia/artifacts/541477a5cefd778e4ecbd314cfbc99eed20f2c4c/include/Rtypes.h:124:16
2627
t.method("ROOT!AddClass", [](const char * arg0, int16_t arg1, const std::type_info & arg2, DictFuncPtr_t arg3, int32_t arg4)->void { ROOT::AddClass(arg0, (Version_t)arg1, arg2, arg3, (Int_t)arg4); }, jlcxx::arg("this"), jlcxx::arg("cname"), jlcxx::arg("id"), jlcxx::arg("info"), jlcxx::arg("dict"), jlcxx::arg("pragmabits"));
28+
*/
2729

2830
DEBUG_MSG("Adding wrapper for void ::ROOT::RemoveClass(const char *, TClass *) (" __HERE__ ")");
2931
// signature to use in the veto list: void ::ROOT::RemoveClass(const char *, TClass *)
@@ -1060,10 +1062,13 @@ struct JlGlobal: public Wrapper {
10601062

10611063
module_.unset_override_module();
10621064

1065+
/*Link fails on ARM64
10631066
DEBUG_MSG("Adding wrapper for void ::ROOT::AddClass(const char *, Version_t, DictFuncPtr_t, Int_t) (" __HERE__ ")");
10641067
// signature to use in the veto list: void ::ROOT::AddClass(const char *, Version_t, DictFuncPtr_t, Int_t)
10651068
// defined in /home/pgras/.julia/artifacts/541477a5cefd778e4ecbd314cfbc99eed20f2c4c/include/TClassTable.h:100:16
10661069
t.method("ROOT!AddClass", [](const char * arg0, int16_t arg1, DictFuncPtr_t arg2, int32_t arg3)->void { ROOT::AddClass(arg0, (Version_t)arg1, arg2, (Int_t)arg3); }, jlcxx::arg("this"), jlcxx::arg("cname"), jlcxx::arg("id"), jlcxx::arg("dict"), jlcxx::arg("pragmabits"));
1070+
*/
1071+
10671072
module_.set_override_module(jl_base_module);
10681073

10691074
DEBUG_MSG("Adding wrapper for TBuffer & ::operator>>(TBuffer &, TArrayL *&) (" __HERE__ ")");

deps/src/Wrapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef WRAPPER_H
2+
#define WRAPPER_H
13
#include "jlcxx/jlcxx.hpp"
24

35
struct Wrapper{
@@ -8,3 +10,4 @@ struct Wrapper{
810
protected:
911
jlcxx::Module& module_;
1012
};
13+
#endif //WRAPPER_H not defined

deps/src/jlROOT.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef JLROOT_H
2+
#define JLROOT_H
13
#include "TVectorT.h"
24
#include "cstdint"
35
#include "Buttons.h"
@@ -301,3 +303,4 @@
301303
#include "TVirtualGeoPainter.h"
302304
#include "TVirtualGeoTrack.h"
303305
#include "TVirtualMagField.h"
306+
#endif //JLROOT_H not defined

deps/src/pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "Failed to use precompile headers."

src/CxxBuild.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535
# Build the libroot_julia library for the ROOT libraries installed under rootsys directory.
3636
# Return the full path to libroot_julia or an empty string in case of failure.
3737
#
38-
function build_root_wrapper(rootsys = ROOTprefs.get_ROOTSYS())
38+
function build_root_wrapper(rootsys=ROOTprefs.get_ROOTSYS(); nobuild=false)
3939

4040
rootconfig = joinpath(rootsys, "bin", "root-config")
4141
used_root_version = readchomp(`$rootconfig --version`)
@@ -51,9 +51,10 @@ function build_root_wrapper(rootsys = ROOTprefs.get_ROOTSYS())
5151
CXXWRAP_PREFIX = CxxWrap.prefix_path()
5252
JL_SHARE = joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia")
5353
JULIA = joinpath(Sys.BINDIR, "julia")
54+
JLCXX_HAS_RANGES = isdefined(CxxWrap.StdLib, :HAS_RANGES) ? 1 : 0
5455
depsdir = joinpath(dirname(@__DIR__), "deps")
5556
srcdir = joinpath(depsdir, "src")
56-
cmd=`make -C "$depsdir" BUILD_DIR="$buildpath" CXXWRAP_PREFIX="$CXXWRAP_PREFIX" JL_SHARE="$JL_SHARE" JULIA="$JULIA" ROOT_CONFIG="$rootconfig" -j $(Sys.CPU_THREADS) VDT_DIR="$(VDT_jll.artifact_dir)"`
57+
cmd=`make -C "$depsdir" BUILD_DIR="$buildpath" CXXWRAP_PREFIX="$CXXWRAP_PREFIX" JL_SHARE="$JL_SHARE" JULIA="$JULIA" ROOT_CONFIG="$rootconfig" -j $(Sys.CPU_THREADS) VDT_DIR="$(VDT_jll.artifact_dir)" JLCXX_HAS_RANGES=$(JLCXX_HAS_RANGES)`
5758
extra_make_options = ROOTprefs._load_preference("extra_make_options", "")
5859
if !isempty(extra_make_options)
5960
cmd = Cmd([collect(cmd)..., extra_make_options])
@@ -80,7 +81,7 @@ function build_root_wrapper(rootsys = ROOTprefs.get_ROOTSYS())
8081
end
8182
end
8283

83-
build = true
84+
libready = false
8485

8586
#Check if library is already built and up-to-date. Returns if it's the case.
8687
sigfile = joinpath(scratch, "sig")
@@ -90,12 +91,22 @@ function build_root_wrapper(rootsys = ROOTprefs.get_ROOTSYS())
9091
oldsig = readline(sigfile)
9192
if newsig == oldsig
9293
@info "Library $libpath is already up-to-date."
93-
build = false
94+
libready = true
9495
end
9596
t1 = time()
9697
@info "Time spent to check for modifications in the ROOT-julia library source code that would require a compilation: $(round(t1-t0, digits=2)) s"
9798
end
9899

100+
build = if libready
101+
false
102+
elseif nobuild
103+
libpath = ""
104+
@info "Build skipped as required by the no_auto_compile preference setting."
105+
false
106+
else
107+
true
108+
end
109+
99110
if build
100111
@info "Build command: " * string(cmd)[2:end-1] * " executed in " * pwd() * " directory."
101112

@@ -248,7 +259,7 @@ function check_rootsys()
248259
end
249260

250261

251-
function get_or_build_libroot_julia()
262+
function get_or_build_libroot_julia(;nobuild=false)
252263

253264
if get_use_root_jll() && is_jll_supported()
254265
#prebuilt wrapper used, no build to perform
@@ -285,7 +296,7 @@ function get_or_build_libroot_julia()
285296
end
286297
end
287298

288-
libpath = build_root_wrapper(rootsys)
299+
libpath = build_root_wrapper(rootsys, nobuild=nobuild)
289300

290301
if !isempty(libpath) && rootsys != pref_rootsys
291302
#If build succeeded and ROOTSYS was modified, update LocalPreference.toml

0 commit comments

Comments
 (0)