Parallel-NetCDF / PnetCDF

Source code repository of PnetCDF library and utilities
https://parallel-netcdf.github.io
Other
83 stars 23 forks source link

Binaries built by SEQ_CC do not use build flags such as CFLAGS CPPFLAGS LDFLAGS #121

Closed loqs closed 9 months ago

loqs commented 9 months ago

This was partially addressed in https://github.com/Parallel-NetCDF/PnetCDF/commit/5d8cfaab2c7690bcf0aede2516f7c648b6495886 which was reverted in https://github.com/Parallel-NetCDF/PnetCDF/commit/000d67f88266890b9af15a85ff2e090a7bf341a5. I am currently working around this with SEQ_CC="$CC $CPPFLAGS $CFLAGS $LDFLAGS" to add hardening such as FULL RELRO to cdfdiff ncoffsets pnetcdf-openmpi ncvalidator. PnetCDF checkpoint.1.12.3 built using:

./configure --prefix=/usr --enable-shared --enable-netcdf4
make
wkliao commented 9 months ago

Reusing CFLAGS for MPI compilers when compiling utility programs designed to run sequentially can cause problems in the cross-compile environment.

One way to solve the problem in your case is to introduce new environment variables, such as SEQ_CFLAGS and SEQ_LDFLAGS. Will that work for your case? e.g.

./configure SEQ_CC=gcc SEQ_CFLAGS="-Wl,-z,relro,-z,now" SEQ_LDFLAGS="-lc"
loqs commented 9 months ago

New environment variables would work for my use case. Thank you very much for the fast response and explanation of the issue.

wkliao commented 9 months ago

Three environment variables SEQ_CFLAGS, SEQ_LDFLAGS, and SEQ_LIBS have been added in PR #122, which has also been merged into the master branch. If you would like to give it a try, please let me know if that works.

loqs commented 9 months ago

I have tried #122 and with SEQ_CFLAGS and SEQ_LDFLAGS set and the options are being applied. Thank you for the fast fix.