Remove $(ASFLAGS) from build system and assemble with $(CFLAGS) instead

We already assemble our assembly files using the $(CC) compiler driver,
rather than the actual $(AS) assembler. This means that

* The C preprocessor gets run on the assembly file
* It's valid to pass gcc-style flags to it, like e.g.
  -mbranch-protection or -fcf-protection
* If you do so, the relevant preprocessor macros like __CET__ get set
* If you really wanted to pass assembler flags, you would need to do
  that using -Wa,... anyway

So I think it makes sense to pass "$(XCFLAGS) $(CFLAGS) $(CPPFLAGS)" to
gcc/clang/etc when assembling, rather than passing $(ASFLAGS) (since
the flags are not actually passed to `as`, but `cc`!).

The side effect of this is that if there are mitigation flags like
-fcf-protection in $CFLAGS, then the relevant macros like __CET__ will
be defined when assembling the files.

[Bug #20601]
This commit is contained in:
KJ Tsanaktsidis 2024-07-06 14:47:02 +10:00
Родитель 087b461c83
Коммит b18701a7ae
2 изменённых файлов: 1 добавлений и 3 удалений

Просмотреть файл

@ -489,7 +489,6 @@ AC_CACHE_CHECK([for $AR flags], [rb_cv_arflags], [
[rb_cv_arflags=rcD], [rb_cv_arflags=rcu])
])
AC_SUBST(ARFLAGS, ["$rb_cv_arflags "])
AC_SUBST(ASFLAGS)
AS_CASE(["$target_os"],
[cygwin*|msys*|mingw*], [

Просмотреть файл

@ -225,7 +225,6 @@ AR = @AR@
ARFLAGS = @ARFLAGS@$(empty)
RANLIB = @RANLIB@
AS = @AS@
ASFLAGS = @ASFLAGS@ $(ARCH_FLAG) $(INCFLAGS)
IFCHANGE = $(SHELL) $(tooldir)/ifchange
OBJDUMP = @OBJDUMP@
OBJCOPY = @OBJCOPY@
@ -449,7 +448,7 @@ $(srcdir)/enc/jis/props.h: enc/jis/props.kwd
.$(ASMEXT).$(OBJEXT):
@$(ECHO) assembling $<
$(Q) $(CC) $(ASFLAGS) -DSYMBOL_PREFIX=$(SYMBOL_PREFIX) -o $@ -c $<
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -DSYMBOL_PREFIX=$(SYMBOL_PREFIX) -c $<
.c.$(ASMEXT):
@$(ECHO) translating $<