pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
 BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file?
2+ messages / 2 participants
[nested] [flat]

*  BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file?
@ 2022-04-19 03:36 PG Bug reporting form <noreply@postgresql.org>
  2022-04-20 16:21 ` Re: BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file? Peter Eisentraut <peter.eisentraut@enterprisedb.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2022-04-19 03:36 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: wysunxavier@gmail.com

The following bug has been logged on the website:

Bug reference:      17466
Logged by:          xavier
Email address:      wysunxavier@gmail.com
PostgreSQL version: 14.2
Operating system:   CentOS 7.9
Description:        

Hello,
When I try to specify some compilation options in CFLAGS, such as compiling
with macros, when I execute “./configure CFLAGS='-DUSE_TOOLS'”,it will use
'-O0' to compile by default, which is easy to miscompile into a debug
version. I wonder if it is possible to supplement the judgment conditions in
the postgresql source code: If the compilation option is not specified in
CFLAGS, '-O2' is used by default to avoid compiling the wrong debug
version.
I tried making modifications to the configure.ac of master branch.
inline patch 1: configure.ac (+4/-0 lines) download inline-1.patchdiff --git a/configure.ac b/configure.ac index 44d35e1..36e3fc5 100644 --- a/configure.ac +++ b/configure.ac @@ -427,6 +427,10 @@ else fi fi +if [[[ ! $CFLAGS[@] =~ "-O" ]]]; then + CFLAGS="$CFLAGS -O2" +fi + if test "$ac_env_CXXFLAGS_set" = set; then CXXFLAGS=$ac_env_CXXFLAGS_value elif test "${CXXFLAGS+set}" = set; then
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file?
  2022-04-19 03:36  BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file? PG Bug reporting form <noreply@postgresql.org>
@ 2022-04-20 16:21 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2022-04-20 16:21 UTC (permalink / raw)
  To: wysunxavier@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form <noreply@postgresql.org>

On 19.04.22 05:36, PG Bug reporting form wrote:
> When I try to specify some compilation options in CFLAGS, such as compiling
> with macros, when I execute “./configure CFLAGS='-DUSE_TOOLS'”,it will use
> '-O0' to compile by default, which is easy to miscompile into a debug
> version. I wonder if it is possible to supplement the judgment conditions in
> the postgresql source code: If the compilation option is not specified in
> CFLAGS, '-O2' is used by default to avoid compiling the wrong debug
> version.

The use case you are describing is not without merit.  But ultimately, 
the handling of these compiler option variables has decades of history 
behind it, and just poking at that for one specific case is going to 
break someone else's use case somehow.

We generally avoid the need to add CFLAGS to the configure command line 
except in cases where you actually want to override the defaults.  Other 
cases should have a command-line option or perhaps a spot in 
pg_config_manual.h.

In your specific case you could also pass CPPFLAGS instead, which is 
more correct anyway, and it doesn't have a default that you can 
accidentally override.





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-04-20 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 03:36  BUG #17466: Is it possible to supplement the default compilation options of CFLAGS in configure file? PG Bug reporting form <noreply@postgresql.org>
2022-04-20 16:21 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox