Skip to content

Toolchain independence - #717

Draft
wom-bat wants to merge 10 commits into
mainfrom
toolchain_independence
Draft

Toolchain independence#717
wom-bat wants to merge 10 commits into
mainfrom
toolchain_independence

Conversation

@wom-bat

@wom-bat wom-bat commented May 8, 2026

Copy link
Copy Markdown
Contributor

Make sddf build more independent of toolchain.
-- fix warnings from gcc
-- improve common.mk so switching toolchains actually rebuilds things

@wom-bat
wom-bat marked this pull request as draft May 8, 2026 01:05

REBUILD_CANDIDATE_OBJECTS := $(shell find . -name '*.o')
${REBUILD_CANDIDATE_OBJECTS): .EXTRA_PREREQS = ${CHECK_FLAGS_BOARD_HASH}
.EXTRA_PREREQS = ${CHECK_FLAGS_BOARD_HASH}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI Peter: #715. (I suspect this might be the BSD make instead of GNU make thing again? IDK)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be; I will check this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use so many GNUmake idioms I'd be surprised if BSD make builds the system at all.

@midnightveil midnightveil May 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make make error if it's not GNUmake? That would solve this as well, I think. (I do recall us decided that we basically need GNUmake: our CI needs it explicitly)

@midnightveil midnightveil May 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: macOS default is GNUmake 3.8, from 2006...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't know what the difference is but @0aids was reporting that $^ was including all the dependencies from this and breaking their build.

I don't know what the difference is between them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean with 'EXTRA_PREREQS' or with Courtney's patch? Either way, we're adding a prerequisite to ensure that stuff is rebuilt; and $^ is the list of all prerequisites except the ones in EXTRA_PREREQS -- Courtney's patch will add the hash file 6to the list; this patch will not.

@midnightveil midnightveil Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Courtney's patch. But it also included all the .h files listed in the compiler emitted .d files.

What confuses me is I don't see what the difference is because the list of dependencies in the compiler-depfile would contain the headers always but why does it only sometimes appear in $^. And when we tested this with two files one included the dependencies in the other file didn't appear in $^.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the first run, the .d files haven't been created, so Make doesn't know about the header files. On subsequent runs it does. A prerequisite in Make terms is any file, that if newer than a target, means the target has to be rebuilt: any header file a C file includes, if changed, means that the .o target needs rebuilding. So the complete prerequisite list for a .o file will always include the C file it is built from, and the transitive closure of header files that that C file includes directly or recursively.

There is almost never a reason to use $^ in a Makefile rule;

@midnightveil midnightveil Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, a lot of our Makefile rules do...

In some ways I think we need to redo all our Makefiles to be of better quality. At the moment they have a hodegpoge of styles and techniques, but at the same time I don't know of any golden references.

Comment thread examples/blk/blk.mk


IMAGES := blk_driver.elf client.elf blk_virt.elf serial_virt_tx.elf serial_driver.elf
CFLAGS += -Wall -Wno-unused-function -Werror -Wno-unused-command-line-argument \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand wanting to remove these disabled warnings but it has nothing to do with GCC vs Clang... These should be separate commits not squished in with the rest silently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is GCC-versus clang ... the arguments are not available for gcc, and the warnings they suppress need to be fixed in-line in the code instead.

@midnightveil midnightveil May 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCC doesn't support -Wno-unused-function? but it says it does: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-function (and I'm pretty sure these pre-date clang-as-default).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wunused-command-line-argument is the one it doesn't seem to accept... and if we can get rid of them, let's go ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can get rid of -Wunused-command-line-argument unfortunately, there's some issues with the Nix-packaged sysroots, and a few other cases.

@wom-bat
wom-bat force-pushed the toolchain_independence branch 3 times, most recently from 55be0f0 to e017a3e Compare May 12, 2026 23:53
wom-bat added 9 commits May 13, 2026 09:54
Gcc complains about a multi-line // comment.  Fix it.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
GCC complained about an unused variable: remove it.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
This means we can get of the -Wno-unused-function compiler arg that is
unrecognised by GCC.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
Extend the board-hash to include TOOLCHAIN and make it so *everything*
depends on it.
Make clang the default toolchain
Allow parent Makefiles to add to the flags depended on.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
Extends flags with NVME and PARTITION so changing them forces a
rebuild.
Passes down Makefile flags to submake.
Reformat slightly for clarity

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
This allows compilation ... there are some debug print helper
functions in a block.h header file.
 -- Mark them inline so they don't get expanded if not used
 -- Mark them __attribute__((unused) to make sure the compiler doesn't
    complain.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
to make the style checker happy.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
in mmio.c -- clang complains about unused functions.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
Fix style in timer/apb_timer/timer.c blk/mmc/imx/usdhc.c and Makefiles

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
@wom-bat
wom-bat force-pushed the toolchain_independence branch from e017a3e to 2bb2ae4 Compare May 12, 2026 23:54
Comment thread examples/blk/blk.mk Outdated
This is now set in common.mk.

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants