feat: exec Fortran compiles via argv (posix_spawn/CreateProcess)#1299
Open
krystophny wants to merge 2 commits into
Open
feat: exec Fortran compiles via argv (posix_spawn/CreateProcess)#1299krystophny wants to merge 2 commits into
krystophny wants to merge 2 commits into
Conversation
Extend the argv-based Fortran compile spawn to Windows so it no longer falls back to the shell there. Tokenize with the OS-native lexer (ms_split on Windows, sh_split on Unix) so backslash paths and quoting survive, route run_argv through c_run_argv on both platforms, and add a CreateProcessA path with per-process stdout/stderr redirect. The shell run remains as a fallback when the spawn returns a negative status. Windows std handles are only overridden when redirecting, to avoid stripping the child console; out-of-range child exit codes are clamped positive so they are not mistaken for the spawn-failure sentinel.
This was referenced Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
a
/bin/sh -c(orcmd /c) string, on both Unix and Windowsposix_spawnp(Unix) andCreateProcess(Windows) are theasync/multithread-safe replacements for fork+exec
run(), so this can only degrade to prior behavior, never break the buildWhy this is a safety fix, not just a speedup
execute_command_lineusessystem(3), which forks, and concurrent fork froma multithreaded (OpenMP) process is documented non-thread-safe. Commit
bb891e3frecords a real observed failure (ar argument truncation on macOS-14gcc 13 in CI) and works around it by wrapping link/archive in
critical(run_command), noting the compile path carries the same latent race.Spawning the compiler by argv removes that race on the compile path and removes
the shell entirely, so quoting/escaping fragility and the shell command-length
ceiling go away too.
Merge order
This is PR 1 of 3 in the argv spawn chain. Merge in order:
Refs: #962
Verification
Unix, OpenMP active:
A freshly built binary builds and runs a sample project through the argv path.
The C file cross-compiles cleanly with
x86_64-w64-mingw32-gcc -Wall -Wextra.