Skip to content

Conversation

practicalswift
Copy link
Contributor

Cherry-picked (and rebased) 9418964 from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (#12695).

See previous review in #12695.

Various changes:

 * Don't check $GCC and $GXX
 * Prefer -Og instead of -O0
 * If -g3 isn't available, use -g

This also incidentally fixes compiler warnings with GCC and glibc when using
--enable-debug, as the old default values mixed poorly with the hardening flags.
@practicalswift
Copy link
Contributor Author

practicalswift commented Apr 17, 2018

One small thing that needs to be fixed before merge is that CPPFLAGS, CXXFLAGS and LDFLAGS gets stuffed with redundant spaces when printing which looks a bit messy:

$ ./configure
…
  CC            = gcc
  CFLAGS        = -g -O2
  CPPFLAGS      =   -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
  CXX           = g++ -std=c++11
  CXXFLAGS      =   -Wstack-protector -fstack-protector-all   -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter
  LDFLAGS       = -pthread  -Wl,-z,relro -Wl,-z,now -pie
  ARFLAGS       = cr

I'll find a way to fix that.

@practicalswift
Copy link
Contributor Author

practicalswift commented Apr 17, 2018

Added a commit fixing the annoying extra whitespace:

$ ./configure
…
  CC            = gcc
  CFLAGS        = -g -O2
  CPPFLAGS      = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
  CXX           = g++ -std=c++11
  CXXFLAGS      = -Wstack-protector -fstack-protector-all -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter
  LDFLAGS       = -pthread -Wl,-z,relro -Wl,-z,now -pie
  ARFLAGS       = cr

Please review :-)

@practicalswift practicalswift force-pushed the enabledebug-again branch 2 times, most recently from f99689a to 8a0ad1a Compare April 17, 2018 10:05
@laanwj
Copy link
Member

laanwj commented Apr 18, 2018

re-utACK
Ping @theuni - he proposed some changes in #12695, so would like to know if he's ok with the current state.

@ryanofsky
Copy link
Contributor

utACK 8a0ad1a2333b329d6eb8d34a25277181ee675f23. The first commit is just rebased and has no changes since my previous review in the other PR. The second commit is new and looks ok, though I think the echo_joined function is overkill. I think you should just drop quotes around the variables and let the shell collapse spaces:

echo "  CXXFLAGS      =" $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $ERROR_CXXFLAGS $CXXFLAGS

@theuni
Copy link
Member

theuni commented Apr 18, 2018

Agree with @ryanofsky about echo_joined. I'd prefer to just drop the second commit.
utACK otherwise.

@eklitzke
Copy link
Contributor

eklitzke commented Apr 19, 2018

Apologies, I was travelling without access to my laptop while this was put up for grabs. This seems fine but I think we came to the conclusion that we should not try to join the output, which was where my first commit was at. We can fix the whitespace formatting in another pass using AX_APPEND_COMPILE_FLAGS.

@practicalswift
Copy link
Contributor Author

@eklitzke Good idea about fixing the whitespace with AX_APPEND_COMPILE_FLAGS. Could you help with a diff for that?

@theuni
Copy link
Member

theuni commented May 8, 2018

@practicalswift That's worth handling in a separate PR. It will be a pretty huge diff.

@practicalswift
Copy link
Contributor Author

@theuni Oh, I see.

@eklitzke @theuni Assuming AX_APPEND_COMPILE_FLAGS is fixed in a follow-up PR do you have time re-review this PR as-is and give your ACK/utACK/NACK? :-)

@fanquake
Copy link
Member

fanquake commented May 9, 2018

@practicalswift From reading the above discussion, and on the original PR, you still need to drop the second commit. Then this can be reviewed, and a follow-up PR can introduce the AX_APPEND_FLAG / AX_APPEND_COMPILE_FLAGS changes.

@practicalswift
Copy link
Contributor Author

@fanquake Updated! Please re-review! :-)

@laanwj
Copy link
Member

laanwj commented May 14, 2018

re-utACK 9e49db2

@laanwj laanwj merged commit 9e49db2 into bitcoin:master May 14, 2018
laanwj added a commit that referenced this pull request May 14, 2018
9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 9418964 from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (#12695).

  See previous review in #12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
[-Og],
[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Og"]],
[AX_CHECK_COMPILE_FLAG([-O0],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]])],
[[$CXXFLAG_WERROR]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if -Og and -O0 are unavailable? (Both of these may compromise spectre mitigations, so I have my x86 compiler not support them at all)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! @eklitzke, what do you say? :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer making this -O1. Completely un-optimized code barely resembles anything that ever gets run, and macro/inline expansions make it hard to deal with anyway.

zkbot added a commit to zcash/zcash that referenced this pull request Jan 30, 2020
@practicalswift practicalswift deleted the enabledebug-again branch April 10, 2021 19:34
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request May 21, 2021
9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 9418964 from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (bitcoin#12695).

  See previous review in bitcoin#12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request May 25, 2021
9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 9418964 from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (bitcoin#12695).

  See previous review in bitcoin#12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 19, 2022
9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 9418964 from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (bitcoin#12695).

  See previous review in bitcoin#12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants