Skip to content

Making huf_decompress_amd64.S does not use ASFLAGS like it should #3006

@noloader

Description

@noloader

Describe the bug
I'm testing Zstd v1.5.1. The tests use various combinations of CPPFLAGS, CFLAGS, CXXFLAGS and LDFLAGS. I also set ASFLAGS to -Wa,--noexecstack when ASM files are present.

It appears the recipe to build huf_decompress_amd64.o from huf_decompress_amd64.S does not use ASFLAGS. In the execution below ASFLAGS=-Wa,--noexecstack, but the option is never used in the invocation:

/usr/bin/cc -g3 -O1 -fsanitize=undefined -fno-sanitize=integer-divide-by-zero -f
no-sanitize=float-divide-by-zero -fno-sanitize-recover=all -march=native -fPIC -
pthread -O3 -DBACKTRACE_ENABLE=0  -I/home/jwalton/tmp/ok2delete-ubsan/include -D
NDEBUG -DTEST_UBSAN=1 -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=0 -DZSTD_LEGACY_SUPPORT
=5 -DZSTD_MULTITHREAD -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS   -DZSTD_LEGACY_SUPP
ORT=5  -c -o obj/conf_0ea01e346cb27c647b1cdb35fd7e9962/huf_decompress_amd64.o ..
/lib/decompress/huf_decompress_amd64.S

Recipes that build assembler files must use ASFLAGS. If the assembler is invoked directly, then ASFLAGS=--noexecstack. If the assembler is invoked through the compiler driver (like above), then ASFLAGS=-Wa,--noexecstack. Also see Variables Used by Implicit Rules in the make manual.

To Reproduce
Steps to reproduce the behavior:

  1. Downloads Zstd v1.5.1
  2. Configure with flags shown below
  3. See the problem

Expected behavior
The compiler or assembler should be invoked with ASFLAGS to pass options to the assembler when assembling asm files.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04, x86_64, full patched
  • Version: Ubuntu 20.04, x86_64, full patched
  • Compiler: GCC 9.3.0
  • Flags: see below
  • Other relevant hardware specs: Core i7-8700, 12 cores
  • Build system: GNU Make

Here are the flags I am using for testing. I realize Zstd is not an Autotools project, and x86_64-pc-linux-gnu will be ignored.

 AUTOCONF_BUILD: x86_64-pc-linux-gnu
PKG_CONFIG_PATH: /home/jwalton/tmp/ok2delete-ubsan/lib/pkgconfig
       CPPFLAGS: -I/home/jwalton/tmp/ok2delete-ubsan/include -DNDEBUG -DTEST_UBSAN=1
        ASFLAGS: -Wa,--noexecstack
         CFLAGS: -g3 -O1 -fsanitize=undefined -fno-sanitize=integer-divide-by-zero -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all -march=native -fPIC -pthread
       CXXFLAGS: -g3 -O1 -fsanitize=undefined -fno-sanitize=integer-divide-by-zero -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all -march=native -fPIC -pthread
        LDFLAGS: -L/home/jwalton/tmp/ok2delete-ubsan/lib -fsanitize=undefined -fno-sanitize=integer-divide-by-zero -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all -Wl,-R,'$ORIGIN/../lib' -Wl,-R,/home/jwalton/tmp/ok2delete-ubsan/lib -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,origin
         LDLIBS: -ldl -lpthread

And according to make, the default recipes use the following implicit variables:

$ make -p | grep -B 1 ASFLAGS
# default
LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)
--
# default
LINK.s = $(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)
--
# default
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
--
# default
COMPILE.s = $(AS) $(ASFLAGS) $(TARGET_MACH)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions