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)}")