Skip to content

Commit

Permalink
Load macros from data dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Nov 30, 2023
1 parent f17e47e commit e4e8cdc
Show file tree
Hide file tree
Showing 20 changed files with 1,191 additions and 12 deletions.
62 changes: 62 additions & 0 deletions crates/boulder/data/macros/actions/autotools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
actions:

# Perform ./configure with the default options
- configure:
command: |
test -x ./configure || ( echo "%%configure: The ./configure script could not be found" ; exit 1 )
./configure %(options_configure)
dependencies:
- autoconf
- automake

# Perform a make
# TIP: Add V=1 VERBOSE=1 after '%make' in the recipe if you need a more verbose build
- make:
command: |
make -j "%(jobs)"
dependencies:
- make

# Install results of build to the destination directory
- make_install:
command: |
%make install DESTDIR="%(installroot)"
dependencies:
- make

# Re autotools-configure a project without an autogen.sh script
- reconfigure:
command: |
autoreconf -vfi || ( echo "%%reconfigure: Failed to run autoreconf"; exit 1 )
%configure
dependencies:
- autoconf
- automake

# Run autogen.sh script, attempting to only configure once
- autogen:
command: |
NOCONFIGURE="noconfigure"; export NOCONFIGURE
sh ./autogen.sh %(options_configure)
./configure %(options_configure)
dependencies:
- autoconf
- automake

definitions:

# Default configuration options as passed to configure
- options_configure: |
--prefix="%(prefix)" \
--bindir="%(bindir)" \
--sbindir="%(sbindir)" \
--build="%(build_platform)" \
--host="%(host_platform)" \
--libdir="%(libdir)" \
--mandir="%(mandir)" \
--infodir="%(infodir)" \
--datadir="%(datadir)" \
--sysconfdir="%(sysconfdir)" \
--localstatedir="%(localstatedir)" \
--sharedstatedir="%(sharedstatedir)" \
--libexecdir="%(libexecdir)"
44 changes: 44 additions & 0 deletions crates/boulder/data/macros/actions/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
actions:

# Perform cmake with the default options in a subdirectory
- cmake:
command: |
cmake %(options_cmake)
dependencies:
- cmake

# Perform cmake with unity build enabled
- cmake_unity:
command: |
cmake -DCMAKE_UNITY_BUILD=ON %(options_cmake)
dependencies:
- cmake

# Build the cmake project
- cmake_build:
command: |
ninja -v -j "%(jobs)" -C "%(builddir)"
dependencies:
- ninja

# Install results of the build to the destination directory
- cmake_install:
command: |
DESTDIR="%(installroot)" ninja install -v -j "%(jobs)" -C "%(builddir)"
dependencies:
- ninja

definitions:

# Default cmake options as passed to cmake
- options_cmake: |
-G Ninja -S . -B "%(builddir)" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_C_FLAGS_RELEASE="" \
-DCMAKE_CXX_FLAGS_RELEASE="" \
-DCMAKE_LD_FLAGS="${LDFLAGS}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_INSTALL_PREFIX="%(prefix)" \
-DCMAKE_LIB_SUFFIX="%(libsuffix)"
43 changes: 43 additions & 0 deletions crates/boulder/data/macros/actions/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
actions:

# Run meson with the default options in a subdirectory
- meson:
command: |
test -e ./meson.build || ( echo "%%meson: The ./meson.build script could not be found" ; exit 1 )
CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" meson setup %(options_meson)
dependencies:
- meson

# Run meson with unity build enabled
- meson_unity:
command: |
test -e ./meson.build || ( echo "%%meson: The ./meson.build script could not be found" ; exit 1 )
CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" meson setup --unity on %(options_meson)
dependencies:
- meson

# Build the meson project
- meson_build:
command: |
meson compile -v -j "%(jobs)" -C "%(builddir)"
dependencies:
- meson

# Install results of the build to the destination directory
- meson_install:
command: |
DESTDIR="%(installroot)" meson install --no-rebuild -v -j "%(jobs)" -C "%(builddir)"
dependencies:
- meson

definitions:

# Default meson options as passed to meson
- options_meson: |
--prefix="%(prefix)" \
--buildtype="plain" \
--libdir="lib%(libsuffix)" \
--libexecdir="lib%(libsuffix)/%(name)" \
--sysconfdir="%(sysconfdir)" \
--localstatedir="%(localstatedir)" \
"%(builddir)"
53 changes: 53 additions & 0 deletions crates/boulder/data/macros/actions/misc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
actions:

# Install files to %(bindir)
- install_bin:
command: |
install -Dm00755 -t %(installroot)/%(bindir)
# Macro to create an empty directory
- install_dir:
command: |
install -dm00755
# Macro to install a file with default executable permissions
- install_exe:
command: |
install -Dm00755
# Macro to install a file without executable permissions
- install_file:
command: |
install -Dm00644
# Patch sources from file
# Usage: %patch %(pkgdir)/${file}
# If you need to override -p#, add it after ${file}
# Example: %patch %(pkgdir)/some.patch -p3
- patch:
command: |
patch -f -p1 -i
dependencies:
- patch

# Create a tmpfiles.d file for the package with given content
- tmpfiles:
command: |
create_tmpfiles(){
if [ -z "%(libsuffix)" ]; then
mkdir -p %(installroot)/%(tmpfilesdir)
echo "$@" >> %(installroot)/%(tmpfilesdir)/%(name).conf
fi
}
create_tmpfiles
# Create a sysusers.d file for the package with given content
- sysusers:
command: |
create_sysusers(){
if [ -z "%(libsuffix)" ]; then
mkdir -p %(installroot)/%(sysusersdir)
echo "$@" >> %(installroot)/%(sysusersdir)/%(name).conf
fi
}
create_sysusers
124 changes: 124 additions & 0 deletions crates/boulder/data/macros/actions/pgo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
actions:
# Actions required for PGO builds

# Merge LLVM profile data, copies to combined.profdata in case there's no stage2
- llvm_merge_s1:
command: |
llvm-profdata merge --failure-mode=all -output=%(pgo_dir)/ir.profdata %(pgo_dir)/IR/default*.profraw
cp %(pgo_dir)/ir.profdata %(pgo_dir)/combined.profdata
# Merge LLVM profile data after stage2 PGO workload
- llvm_merge_s2:
command: |
rm %(pgo_dir)/combined.profdata
llvm-profdata merge --failure-mode=all -output=%(pgo_dir)/combined.profdata %(pgo_dir)/ir.profdata %(pgo_dir)/CS/default*.profraw
# Instrument file with llvm-bolt
- bolt_instr:
command: |
binstr(){
mv ${1} ${1}.orig
mkdir -p %(pgo_dir)/BOLT
llvm-bolt ${1}.orig -instrument --instrumentation-file=%(pgo_dir)/BOLT/$(basename ${1}) --instrumentation-file-append-pid ${2} ${3} ${4} -o ${1}
}
binstr
# Instrument file with llvm-bolt
- bolt_merge:
command: |
bmerge(){
merge-fdata %(pgo_dir)/BOLT/$(basename ${1}).*.fdata > %(pgo_dir)/$(basename ${1}).fdata
}
bmerge
# Apply bolt profile
- bolt_opt:
command: |
boptim(){
llvm-bolt ${1}.orig -o ${1}.bolt -data=%(pgo_dir)/$(basename ${1}).fdata -reorder-blocks=cache+ -reorder-functions=hfsort+ -split-functions=3 -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack ${2} ${3} ${4}
cp ${1}.bolt ${1}
}
boptim
dependencies:
- llvm-bolt

# Collect perf data suitable for the bolt macros
- bolt_perf:
command: |
bperf(){
mkdir -p %(pgo_dir)/BOLT
perf record -F 6000 -e cycles:u -j any,u -o %(pgo_dir)/BOLT/perf.data -- ${@}
}
bperf
dependencies:
- perf

# Convert perf data into bolt equivalent
- bolt_perf2bolt:
command: |
bperf2bolt(){
cp ${1} ${1}.orig
perf2bolt -ignore-build-id -p %(pgo_dir)/BOLT/perf.data -o %(pgo_dir)/$(basename ${1}).fdata ${1}
}
bperf2bolt
tuning :
# A set of groups we can toggle from the "tune" key

# Enable pgosample
- pgosample:
enabled: pgosample

# Enable pgostage1
- pgostage1:
enabled: pgostage1

# Enable pgostage2
- pgostage2:
enabled: pgostage2

# Enable pgouse
- pgouse:
enabled: pgouse

flags :
# PGO flag options

# PGO sample flags for when workload is not comprehensive (workload builds only)
- pgosample:
llvm:
c : "-fno-profile-sample-accurate"
cxx : "-fno-profile-sample-accurate"
ld : "-fno-profile-sample-accurate"
gnu:
c : "-fprofile-partial-training"
cxx : "-fprofile-partial-training"
ld : "-fprofile-partial-training"

# PGO stage1 flags for ProfileStage1 (workload builds only)
- pgostage1:
llvm:
c : "-fprofile-generate=%(pgo_dir)/IR"
cxx : "-fprofile-generate=%(pgo_dir)/IR"
ld : "-fprofile-generate=%(pgo_dir)/IR"
gnu:
c : "-fprofile-generate -fprofile-dir=%(pgo_dir)"
cxx : "-fprofile-generate -fprofile-dir=%(pgo_dir)"
ld : "-fprofile-generate -fprofile-dir=%(pgo_dir)"

# PGO stage2 flags for ProfileStage2 (workload builds only)
- pgostage2:
llvm:
c : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"
cxx : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"
ld : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"

# PGO final flags for ProfileUse (workload builds only)
- pgouse:
llvm:
c : "-fprofile-use=%(pgo_dir)/combined.profdata"
cxx : "-fprofile-use=%(pgo_dir)/combined.profdata"
ld : "-fprofile-use=%(pgo_dir)/combined.profdata"
gnu:
c : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"
cxx : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"
ld : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"
31 changes: 31 additions & 0 deletions crates/boulder/data/macros/actions/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
actions:

# Perform python setup and build with the default options
- python:
command: |
test -e ./setup.py || ( echo "%%python: The ./setup.py script could not be found" ; exit 1 )
python3 setup.py build
dependencies:
- python

# Install python package to the destination directory
- python_install:
command: |
python3 setup.py install --root="%(installroot)"
dependencies:
- python

# Build a wheel for python PEP517 projects
- pyproject_build:
command: |
python3 -m build --wheel --no-isolation
dependencies:
- python-build
- python-wheel

# Install wheel to destination directory
- pyproject_install:
command: |
python3 -m installer --destdir="%(installroot)" dist/*.whl
dependencies:
- python-installer
23 changes: 23 additions & 0 deletions crates/boulder/data/macros/arch/aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Provides -m64 builds for aarch64 build-hosts

definitions:

- libsuffix : ""
- build_platform : aarch64-%(vendorID)
- host_platform : aarch64-%(vendorID)
- cc : "%(compiler_c) -m64"
- cxx : "%(compiler_cxx) -m64"
- cpp : "%(compiler_cpp) -m64"
- march : armv8-a+simd+fp+crypto
- mtune : cortex-a72.cortex-a53

flags:

# Set architecture flags
- architecture:
llvm:
c : "-march=armv8-a+simd+fp+crypto -mtune=cortex-a72"
cxx : "-march=armv8-a+simd+fp+crypto -mtune=cortex-a72"
gcc:
c : "-march=armv8-a+simd+fp+crypto -mtune=cortex-a72.cortex-a53"
cxx : "-march=armv8-a+simd+fp+crypto -mtune=cortex-a72.cortex-a53"
Loading

0 comments on commit e4e8cdc

Please sign in to comment.