-
-
Notifications
You must be signed in to change notification settings - Fork 312
Closed
Labels
BugSomething isn't workingSomething isn't workingFixed needs testingNeeds verification / testing that it now worksNeeds verification / testing that it now works
Milestone
Description
According to c3c --list-manifest-properties both cflags and cflags-override belong among target properties.
But it seems that target cflags are ignored. I created a library somelib.c3l with a single C file lib.c
#ifndef OPT_A
#error "Missing option A"
#endif
#ifndef OPT_B
#error "Missing option B"
#endifand following manifest.json
{
"provides": "somelib",
"cflags": "-DOPT_A",
"c-sources": ["lib.c"],
"targets": {
"macos-aarch64": {
"cflags": "-DOPT_B",
"linked-libraries": ["c"]
}
}
}When using it it I get the error which confirms that cflags in a target has no effect:
./somelib.c3l/lib.c:6:2: error: "Missing option B"
6 | #error "Missing option B"
| ^
1 error generated.
Failed to compile c sources using command 'cc -fPIC -c -DOPT_A ./somelib.c3l/lib.c -o .build/obj/macos-aarch64/somelib/lib.o'.
Experiment with cflags-override
Using cflags-override
{
"provides": "somelib",
"cflags": "-DOPT_A",
"c-sources": ["lib.c"],
"targets": {
"macos-aarch64": {
"cflags-override": "-DOPT_B",
"linked-libraries": ["c"]
}
}
}overrides existing cflags so with the code above it results in
./somelib.c3l/lib.c:2:2: error: "Missing option A"
2 | #error "Missing option A"
| ^
1 error generated.
Failed to compile c sources using command 'cc -fPIC -c -DOPT_B ./somelib.c3l/lib.c -o .build/obj/macos-aarch64/somelib/lib.o'.
which works as expected.
Ideas how to fix this
I think either c3c --list-manifest-properties should be updated to not show cflags under Target properties section.
Or parse_library_target in src/build/libraries.c shall be updated to read cflags of a target and merge them with manifest cflags.
My C3 version
C3 Compiler Version: 0.7.3 (Pre-release, Jun 10 2025 14:55:09)
Git Hash: bbd9f6dc9695c9627bd4b69cd44492ed5833c3a4
Backends: LLVM
LLVM version: 20.1.6
LLVM default target: arm64-apple-darwin24.4.0
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingFixed needs testingNeeds verification / testing that it now worksNeeds verification / testing that it now works