> On Jul 1, 2024, at 5: 21 AM, meator <meator. dev@ gmail. com> wrote: > > Hello, > > I am currently packaging PETSc and have noticed some peculiar behavior when attempting to override CFLAGS, CXXFLAGS, and FFLAGS. > >
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd

> On Jul 1, 2024, at 5:21 AM, meator <meator....@gmail.com> wrote:
> 
> Hello,
> 
> I am currently packaging PETSc and have noticed some peculiar behavior when attempting to override CFLAGS, CXXFLAGS, and FFLAGS.
> 
> Firstly, when calling ./configure with CFLAGS="args" as its argument, it seems to completely override the flag detection system in config/BuildSystem/config/compilerOptions.py (and presumably other places). Same holds true for CXXFLAGS and FFLAGS. This is not desirable for me. With the underlying compiler detected as GCC, I would normally get -fvisibility=hidden and a bunch of extra warnings. These all get lost when CFLAGS or CXXFLAGS is overridden. Is there a way to simply append flags instead of overriding them? Losing flags such as -fvisibility=hidden can severely affect the compiled library.
> 
> Other build systems usually differentiate between mandatory flags that will get included no matter what and overridable flags which may be replaced. It looks like such a system even exists in PETSc, because -fPIC gets included in C flags even when CFLAGS is set. I understand that the situation here is a bit more complex, as PETSc must support a plethora of compilers which use differing flags and compiler wrappers like mpicc are prevalent.

   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.
> 
> I assume that the same issue occurs for FFLAGS. I do not know Fortran, so I cannot evaluate the risks of omitting flags that are included when FFLAGS isn't specified, but I assume that some of the "lost" flags are also of importance.
> 
> Another issue, which I find more severe, is that the overridden flags get included in cflags_extra, cxxflags_extra, and fflags_extra of the generated pkg-config file. This is highly undesirable because the flags used to build PETSc should not be used for compiling user programs. My package template provides flags like -ffile-prefix-map, which make sense when PETSc is being built in a fake destdir to be packaged but do not make sense for user programs.
> 
> The pkg-config file generated by PETSc is something I've never seen before. It took me a considerable amount of time to comprehend the extra keys set there, but I now understand that they are used in the sample Makefile and CMake build definition file.
> 
> I am not 100% certain why this system is in place. Why does the pkg-config file need to provide extra flags and set compilers? I've seen no other pkg-config file which does such things.



> 
> 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?

  Barry
> 
> Thanks in advance
> <OpenPGP_0x1A14CB3464CBE5BF.asc>

Reply via email to