[petsc-users] Weird handling of compiler flags by the build system

meator meator.dev at gmail.com
Mon Jul 1 09:43:26 CDT 2024


Thank you for your reply!

On 7/1/24 4:14 PM, Barry Smith wrote:
>     We have had well over a decade of debates on this issue. I would like to see a CFLAGS+=extra_flags option but that has been resisted. Instead Satish can tell you how to get what you want.

This is unfortunate. I assume that patching the buildsystem or some 
other trickery will be necessary if what you're saying is true.

>> Is there a way to fix the pkg-config file (apart from manually removing cflags_extra, cxxflags_extra, and fflags_extra from the .pc file)?
> 
>      These are there so people can see EXACTLY what flags were used when PETSc was compiled. They are not intended for people using pkg-config to use PETSc when building their package. What is the harm in having these extra flags in the pkgconfig file?

Here is an excerpt from /usr/share/petsc/Makefile.user (this is a 
template Makefile supplied with PETSc for use in custom projects):

 > # Additional libraries that support pkg-config can be added to the 
list of PACKAGES below.
 > PACKAGES := $(petsc.pc)
 >
 > CC := $(shell pkg-config --variable=ccompiler $(PACKAGES))
 > CXX := $(shell pkg-config --variable=cxxcompiler $(PACKAGES))
 > FC := $(shell pkg-config --variable=fcompiler $(PACKAGES))
 > CFLAGS_OTHER := $(shell pkg-config --cflags-only-other $(PACKAGES))
 > CFLAGS := $(shell pkg-config --variable=cflags_extra $(PACKAGES)) 
$(CFLAGS_OTHER)
 > CXXFLAGS := $(shell pkg-config --variable=cxxflags_extra $(PACKAGES)) 
$(CFLAGS_OTHER)
 > FFLAGS := $(shell pkg-config --variable=fflags_extra $(PACKAGES))
 > CPPFLAGS := $(shell pkg-config --cflags-only-I $(PACKAGES))
 > LDFLAGS := $(shell pkg-config --libs-only-L --libs-only-other 
$(PACKAGES))
 > LDFLAGS += $(patsubst -L%, $(shell pkg-config --variable=ldflag_rpath 
$(PACKAGES))%, $(shell pkg-config --libs-only-L $(PACKAGES)))
 > LDLIBS := $(shell pkg-config --libs-only-l $(PACKAGES)) -lm
 > CUDAC := $(shell pkg-config --variable=cudacompiler $(PACKAGES))
 > CUDAC_FLAGS := $(shell pkg-config --variable=cudaflags_extra $(PACKAGES))
 > CUDA_LIB := $(shell pkg-config --variable=cudalib $(PACKAGES))
 > CUDA_INCLUDE := $(shell pkg-config --variable=cudainclude $(PACKAGES))

CFLAGS of user projects get initialized to cflags_extra for people who 
use the official recommended Makefile template. This is not tolerable 
because the flags used for building PETSc may be incompatible with 
unrelated projects that depend on PETSc. The build environment of the 
user program may be very different from the one used to build PETSc 
itself. Users trying to build their custom programs depending on PETSc 
will likely not want flags that were used to build PETSc in a fake 
destdir in chrooted system while building the PETSc package.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x1A14CB3464CBE5BF.asc
Type: application/pgp-keys
Size: 6275 bytes
Desc: OpenPGP public key
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240701/963abb6b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240701/963abb6b/attachment.sig>


More information about the petsc-users mailing list