-
Notifications
You must be signed in to change notification settings - Fork 63
Add support for specifiying a language standard to bmake #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,8 @@ DLL_EXT = <%dll_ext%> | |
| EXE_EXT = <%exe_ext%> | ||
| RC = <%rc%> | ||
| LIBFLAGS = <%libflags%> | ||
| CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%> | ||
| CCFLAGS = $(CC_CFLAGS)<%if(type_is_binary)%> $(BINARY_FLAGS)<%endif%><%if(compile_flags)%> <%compile_flags%><%endif%><%if(languagestandard)%> -std=<%languagestandard%><%endif%> | ||
|
|
||
|
Comment on lines
+100
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainC++ standard flag may be applied to .c compilations — verify this is acceptable or scope to C++ rules only CCFLAGS is used by all compile rules, including .c. Appending -std=c++NN here may (a) be rejected by some compilers for C files, or (b) flip .c files into C++ mode. This can silently change semantics or fail builds in mixed C/C++ projects.
I can provide a follow-up patch that scopes the flag to C++-only rules if you confirm this is needed. 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Repository root: $(pwd)"
echo
echo "1) Show templates/bmake.mpd (first 400 lines):"
echo "------------------------------------------------"
if [ -f "templates/bmake.mpd" ]; then
sed -n '1,400p' templates/bmake.mpd || true
else
echo "templates/bmake.mpd not found"
fi
echo
echo "2) Search for CCFLAGS, -std and compile rule patterns:"
echo "------------------------------------------------"
rg -n --hidden -S 'CCFLAGS|\-std=|languagestandard|%.o: %.c|%.o: %.cpp|%.o: %.cxx|%.o: %.cc|\.c:|\.cpp:|\.cxx:|\.cc:' || true
echo
echo "3) Show lines around occurrences of CCFLAGS:"
echo "------------------------------------------------"
rg -n --hidden -S -n 'CCFLAGS' -n --line-number -n -H -S || true
echo
echo "4) Grep for common compile command usages (CC, CXX, CFLAGS, CXXFLAGS):"
echo "------------------------------------------------"
rg -n --hidden -S '\$\(CC\)|\$\(CXX\)|CFLAGS|CXXFLAGS' || trueLength of output: 27004 Scope -std=<%languagestandard%> to C++ compile rules in templates/bmake.mpd Verified: CCFLAGS contains -std=<%languagestandard%> and that CCFLAGS is used by all compile rules (including .c), so a C++ standard flag will be passed to C compilations. Files/locations to fix
Suggested change (minimal)
Change to: And in the C++ rules (example non-parallel .cpp rule) append the flag: If you want, I can prepare a PR that moves the -std into the C++ rules (or introduces a CPP_STD_FLAGS variable and uses it only for the C++ patterns). 🤖 Prompt for AI Agents |
||
|
|
||
| !ifndef MPC_NUMBER_OF_PROCESSORS | ||
| MPC_NUMBER_OF_PROCESSORS = 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Do not append -std=… to CCFLAGS; it will be applied to C sources too and can break C builds
CCFLAGS is used for both C and C++ compilation rules in this template (.c, .cc, .cxx, .cpp, .C). Adding a C++ -std flag here will propagate to .c compilations, which Clang/GCC will reject (e.g., “invalid argument '-std=c++17' not allowed with 'C'”). This is a latent build break for projects containing C sources.
Minimal fix within this line:
Follow-up (outside this hunk): introduce a separate flag used only by C++ rules and inject it into C++-only compile patterns (.cpp/.cxx/.cc/.C), not .c. Example:
Make variable definition near CCFLAGS:
Update compile commands for C++ sources by adding$(CXX_STD_FLAG) after $ (CCFLAGS), e.g.:
From:
To:
From:
To:
From:
To:
Please confirm whether projects using this template include any .c sources. If they never do, we can keep the current approach; otherwise, the refactor above avoids C builds failing when languagestandard is set.
🏁 Script executed:
Length of output: 327
🏁 Script executed:
Length of output: 23905
Do not put -std= into CCFLAGS — it will be passed to C compilations and can break C builds
Short reason: templates/bmake.mpd currently places -std=<%languagestandard%> inside CCFLAGS (confirmed at templates/bmake.mpd:100). CCFLAGS is used by the .c rule and per-file rules (see templates/bmake.mpd:353–355, 357–362), so C compiler invocations will receive C++ -std flags and may fail.
Files/locations to change
Minimal diffs (apply to templates/bmake.mpd)
Example compile-rule change (repeat for .cpp/.cxx/.cc/.C and parallel .cpp rules):
For per-file rules generated for each source file, conditionally add $(CXX_STD_FLAG) only when that source file is C++:
Please confirm whether projects using this template contain any .c sources; if they do, apply the fix above. If none contain C sources, leaving the current template is harmless but fragile if a .c is later added.
📝 Committable suggestion
🤖 Prompt for AI Agents