[PATCH v1] Filter machine compiler flags into Assembler Flags

Peter Bergner bergner@tenstorrent.com
Wed May 28 19:46:40 GMT 2025


On 5/27/25 8:24 AM, Sachin Monga wrote:
> -mrop-protect is required for ROP compilation which is
> ignored by ASFLAGS for now. Filtering -m% flags will ensure
> that they are copied from CFLAGS to ASFLAGS.

I like what the patch is trying to do, so assuming other people don't have
an issue with the goal of the patch (passing -m* options to ASFLAGS)...

I think this patch is more generally useful than just allowing -mrop-protect
to be passed to ASFLAGS.  Many -mFOO options set predefined macros which asm
files may want to test for, similar to your asm changes testing for
__ROP_PROTECT__, so I think we should generalize the wording on the git log
entry to advertise that.  Maybe something like the following???

Assembler files may want or need to test for predefined macros which are
set via -m* compiler options, so ensure all -m* options in CFLAGS are passed
to ASFLAGS.



>  # The assembler can generate debug information too.
>  ifndef ASFLAGS
> -ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
> +ASFLAGS := $(filter -g% -fdebug-prefix-map=% -m%,$(CFLAGS))
>  endif

This hunk LGTM.



> -override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
> +override ASFLAGS += -Werror=undef $(ASFLAGS-config)

...but I think we should drop this hunk altogether.  If the user
defines ASFLAGS on the command line, then the code from the first
hunk will not be executed and we won't assign asflags-cpu to ASFLAGS
and we'll get whatever -mcpu= option the user added to ASFLAGS (if any),
rather then the one dictated by the --with-cpu= configure option.
We want it to work similarly to cflags-cpu overriding -mcpu= in CFLAGS.
I think it's safe to just leave this code as is.

Peter




More information about the Libc-alpha mailing list