Began porting the mapping system

This commit is contained in:
2026-09-20 14:37:11 -04:00
parent f69fac8f1e
commit 08a8f231d2
46 changed files with 1336 additions and 115 deletions

View File

@@ -384,7 +384,7 @@ def common_cmake_args(
)
c_flags = list(args.c_arg)
cxx_flags = list(args.cxx_arg)
link_flags = list(dict.fromkeys([*args.c_link_arg, *args.cxx_link_arg]))
link_flags = []
if args.host_system == "darwin":
link_flags.append("-Wl,-headerpad_max_install_names")
if args.host_system == "emscripten":
@@ -410,10 +410,24 @@ def common_cmake_args(
result.append(f"-DCMAKE_C_FLAGS={joined_flags(c_flags)}")
if cxx_flags:
result.append(f"-DCMAKE_CXX_FLAGS={joined_flags(cxx_flags)}")
if link_flags:
rendered_link_flags = joined_flags(link_flags)
result.append(f"-DCMAKE_EXE_LINKER_FLAGS={rendered_link_flags}")
result.append(f"-DCMAKE_SHARED_LINKER_FLAGS={rendered_link_flags}")
# CMake's global linker flags apply to both compiler drivers. In particular,
# passing Clang's -stdlib=libc++ to a GCC C compiler breaks its ABI check.
# Apply Meson's language-specific options only to the matching link language.
link_options_file = args.work_dir / "meson-link-options.cmake"
link_options_file.parent.mkdir(parents=True, exist_ok=True)
link_options = []
for language, flags in (("C", args.c_link_arg), ("CXX", args.cxx_link_arg)):
for flag in flags:
escaped = (flag.replace("\\", "\\\\").replace('"', '\\"')
.replace(";", "\\;").replace("$", "\\$"))
# Libraries must follow the object files for --as-needed linkers.
command = "link_libraries" if flag.startswith("-l") else "add_link_options"
link_options.append(f'{command}("$<$<LINK_LANGUAGE:{language}>:{escaped}>")')
link_options_file.write_text("\n".join(link_options) + "\n")
result.append(f"-DCMAKE_PROJECT_INCLUDE={link_options_file}")
rendered_link_flags = joined_flags(link_flags)
for kind in ("EXE", "SHARED", "MODULE"):
result.append(f"-DCMAKE_{kind}_LINKER_FLAGS={rendered_link_flags}")
rpath = runtime_rpath(args.host_system)
if rpath:
result.extend(
@@ -586,7 +600,7 @@ def build_mpich(
local_env = dict(env)
mpich_link_flags = [f"-L{args.prefix / 'lib'}"]
mpich_link_flags.extend([*args.c_link_arg, *args.cxx_link_arg])
mpich_link_flags.extend(args.c_link_arg)
if args.host_system == "darwin":
mpich_link_flags.append("-Wl,-headerpad_max_install_names")
local_env.update(
@@ -597,7 +611,7 @@ def build_mpich(
filter(None, [compiler_flags(build_type), joined_flags(args.c_arg)])
),
"CXXFLAGS": " ".join(
filter(None, [compiler_flags(build_type), joined_flags(args.cxx_arg)])
filter(None, [compiler_flags(build_type), joined_flags([*args.cxx_arg, *args.cxx_link_arg])])
),
"CPPFLAGS": f"-I{args.prefix / 'include'}",
"LDFLAGS": " ".join(mpich_link_flags),
@@ -966,7 +980,8 @@ def build_libceed(
],
)
)
link_flags = [*args.c_link_arg, *args.cxx_link_arg]
# libCEED's shared library is linked by CC, including its CPU backends.
link_flags = list(args.c_link_arg)
if features["openmp"]:
# libCEED's default clang flag (-fopenmp) does not work with Apple Clang.
command.append(f"OMP_FLAG={joined_flags(args.openmp_c_flags)}")

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
"""Verify a sandbox's deliberate uncaught exception, never arbitrary failure."""
import re
import resource
import signal
import subprocess
import sys
def main() -> int:
executable, expected_code = sys.argv[1:]
# These examples deliberately terminate; avoid writing core dumps.
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
result = subprocess.run([executable], capture_output=True, text=True, timeout=25)
sys.stdout.write(result.stdout)
sys.stderr.write(result.stderr)
diagnostic = rf"Error: .*\(code No\.: \d+ \[{re.escape(expected_code)}\]\)"
if result.returncode == -signal.SIGABRT and re.search(diagnostic, result.stderr):
print(f"Verified expected exception: {expected_code}")
return 0
print(
f"Expected SIGABRT with SERiF error {expected_code}; got exit {result.returncode}",
file=sys.stderr,
)
return 1
if __name__ == '__main__':
raise SystemExit(main())

View File

@@ -1,66 +1,42 @@
#!/bin/sh
# Build and run all six sandboxes with each Linux compiler/library/linker pair.
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
meson_bin=${MESON_BIN:-meson}
meson_dir=$(CDPATH= cd -- "$(dirname -- "$meson_bin")" && pwd)
profile=${MFEM_MATRIX_PROFILE:-portable}
profile=${MFEM_MATRIX_PROFILE:-minimal}
jobs=${MFEM_JOBS:-4}
mode=${SERIF_BUILDTYPE:-debug}
compiler_family() {
"$1" --version 2>&1 | sed -n '1p'
}
require_clang() {
version=$(compiler_family "$1")
case "$version" in
*clang*|*Clang*) ;;
*) echo "error: $1 is not a Clang compiler: $version" >&2; exit 2 ;;
# GCC/libc++ requires a recent GCC and Linux headers at /usr/include/c++/v1.
# Set SERIF_TOOLCHAINS to a space-separated subset to test selected toolchains.
for toolchain in ${SERIF_TOOLCHAINS:-gcc gcc-libcxx clang-libstdcxx clang-libcxx}; do
case "$toolchain" in
gcc) compiler=gcc; library= ;;
gcc-libcxx) compiler=gcc; library=gcc-libcxx ;;
clang-libstdcxx) compiler=clang; library=libstdcxx ;;
clang-libcxx) compiler=clang; library=libcxx ;;
*) echo "Unknown toolchain: $toolchain" >&2; exit 2 ;;
esac
}
require_gnu() {
version=$(compiler_family "$1")
case "$version" in
*gcc*|*GCC*|*"Free Software Foundation"*) ;;
*) echo "error: $1 is not a GNU compiler: $version" >&2; exit 2 ;;
esac
}
run_configuration() {
name=$1
c_compiler=$2
cxx_compiler=$3
mode=$4
build_dir="$project_root/build-$name"
if test -f "$build_dir/meson-private/coredata.dat"; then
wipe_flag=--wipe
else
wipe_flag=
fi
env PATH="$meson_dir:$PATH" CC="$c_compiler" CXX="$cxx_compiler" \
"$meson_bin" setup $wipe_flag "$build_dir" "$project_root" \
--buildtype="$mode" \
-Dallow_preinstalled=false \
-Dfeature_profile="$profile" \
-Dbuild_examples=true \
-Dbuild_tests=true \
-Dbuild_python=false \
-Djobs="$jobs"
env PATH="$meson_dir:$PATH" "$meson_bin" compile -C "$build_dir"
env PATH="$meson_dir:$PATH" "$meson_bin" test -C "$build_dir" --print-errorlogs
}
clang_cc=${CLANG_CC:-clang}
clang_cxx=${CLANG_CXX:-clang++}
gcc_cc=${GNU_CC:-gcc}
gcc_cxx=${GNU_CXX:-g++}
require_clang "$clang_cxx"
require_gnu "$gcc_cxx"
run_configuration clang-debug "$clang_cc" "$clang_cxx" debug
run_configuration clang-release "$clang_cc" "$clang_cxx" release
run_configuration gcc-debug "$gcc_cc" "$gcc_cxx" debug
run_configuration gcc-release "$gcc_cc" "$gcc_cxx" release
for linker in ${SERIF_LINKERS:-ld lld}; do
case "$linker" in ld|lld) ;; *) echo "Unknown linker: $linker" >&2; exit 2 ;; esac
build_dir="$project_root/build/matrix/$toolchain-$linker"
set -- "$build_dir" "$project_root" \
"--native-file=$project_root/native/$compiler.ini" \
"--native-file=$project_root/native/$linker.ini" \
"--buildtype=$mode" -Dallow_preinstalled=false \
"-Dfeature_profile=$profile" -Dbuild_tests=true "-Djobs=$jobs"
if test -n "$library"; then
set -- "$@" "--native-file=$project_root/native/$library.ini"
fi
if test -n "${SERIF_SANDBOX_EXPECTED_ERRORS:-}"; then
set -- "$@" "-Dsandbox_expected_errors=$SERIF_SANDBOX_EXPECTED_ERRORS"
fi
if test -f "$build_dir/meson-private/coredata.dat"; then
set -- --reconfigure "$@"
fi
"$meson_bin" setup "$@"
"$meson_bin" compile -C "$build_dir" -j "$jobs"
"$meson_bin" test -C "$build_dir" --print-errorlogs
done
done