Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?
Date: 2025-08-01 04:07:03
Message-ID: 2192626.1754021223@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> writes:
> Thanks for the explanation. W.R.T the PROFILE variable, I tried:

> # ./configure --enable-debug
> # PROFILE="-O0" make

> As a result, both "-O2" and "-O0" presented to gcc. In that case, I believe
> "-O0" will be ignored by gcc.

Nope ... read the gcc docs, or experiment. The last -O switch wins.
(This is true for most switches in most Unix tools, and it's common
for scripts such as Makefiles to rely on it.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-08-01 04:33:03 Re: Logical Replication of sequences
Previous Message Chao Li 2025-08-01 04:01:39 Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?