Skip to content

Commit

Permalink
Include CFLAGS from configure in build of numademo
Browse files Browse the repository at this point in the history
Otherwise, building with hardened settings fails with:

  /usr/bin/ld: numademo-numademo.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
  /usr/bin/ld: numademo-stream_lib.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
  /usr/bin/ld: numademo-mt.o: relocation R_X86_64_32 against symbol `mt_buffer' can not be used when making a PIE object; recompile with -fPIE
  /usr/bin/ld: numademo-clearcache.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:906: numademo] Error 1

The linker still gets LDFLAGS with -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
but the CFLAGS with -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 get clobbered
by this custom setting.

Let's append `$(AM_CFLAGS)` to the beginning of the list, so these are always
preserved when passed.

Tested with:

  $ ./configure \
        CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' \
        LDFLAGS='-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
  • Loading branch information
filbranden committed Sep 18, 2020
1 parent 92d4e7d commit d73332a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ numastat_CFLAGS = $(AM_CFLAGS) -std=gnu99

numademo_SOURCES = numademo.c stream_lib.c stream_lib.h mt.c mt.h clearcache.c clearcache.h
numademo_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_STREAM_LIB -DHAVE_MT -DHAVE_CLEAR_CACHE
numademo_CFLAGS = -O3 -ffast-math -funroll-loops
numademo_CFLAGS = $(AM_CFLAGS) -O3 -ffast-math -funroll-loops
if HAVE_TREE_VECTORIZE
numademo_CFLAGS += -ftree-vectorize
endif
Expand Down

0 comments on commit d73332a

Please sign in to comment.