Skip to content

add -std=c++11 to $CXXFLAGS when building binutils 2.42+ with system GCC 4.8.1 to 5.x#3728

Merged
boegel merged 5 commits intoeasybuilders:developfrom
lijiebio:develop
May 23, 2025
Merged

add -std=c++11 to $CXXFLAGS when building binutils 2.42+ with system GCC 4.8.1 to 5.x#3728
boegel merged 5 commits intoeasybuilders:developfrom
lijiebio:develop

Conversation

@lijiebio
Copy link
Copy Markdown

@lijiebio lijiebio commented May 23, 2025

Comment thread easybuild/easyblocks/b/binutils.py Outdated
and self.toolchain.comp_family() == toolchain.SYSTEM
):
res = run_shell_cmd('g++ --version')
gxx_version = res.output.strip().split(' ')[2]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not strictly correct, it should be

gxx_version = res.output.strip().split(' ')[-1]

Since it is the last part of the output that contains the version.

On Ubuntu [2] would return something similar to "13.3.0-6ubuntu2~24.04)" while [-1] returns "13.3.0"

Also, I don't really know if we want to support a SYSTEM GCC compiler that old...
What is it from?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And this can be easily solved by adding a hook that adds that to configopts (where it should really go) for a site with such an old system gcc.
And it should add -std=c++11 to CXXFLAGS, not override it in the style of the lines above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have a function for this in framework, better use this?

Either get_gcc_version, or get_tool_version('g++') (both from easybuild.tools.systemtools`)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My command to get g++ version is indeed not strictly correct. I will commit after.

gxx_version = res.output.strip().split(' ')[-1]

This is not strictly correct for RHEL-based Linux distributions as well. Maybe g++ -v not g++ --version is better. The last line of g++ -v output string looks easier to parse. I will check it later.

The reason I created this PR is I'm working on CentOS 7 to compile universal binaries targeting glibc 2.17. eb foss-2024a.eb -r will first compile binutils-2.42 with SYSTEM toolchain including gcc-4.8.5. However, gcc-4.8.5 uses the dafault C++ standard (C++ 98) during compilation even if gcc-4.8.5 had already support C++ 11 standard. The build option --std=c++11 must be explicitly specified. This will cause compilation failure, as described in the issue easybuilders/easybuild-easyconfigs#22651.

Next, what is the range of affected versions of gcc? See https://gcc.gnu.org/projects/cxx-status.html.

GCC 4.8.1 was the first feature-complete implementation of the 2011 C++ standard, previously known as C++0x.

So, the start of range is 4.8.1 (include 4.8.1).

This mode is the default in GCC 6.1 up until GCC 10 (inclusive); it can be explicitly selected with the -std=c++14 command-line flag, or -std=gnu++14 to enable GNU extensions as well.

Up util gcc-6.1.0, the default standard changed to C++ 14. So, the end of range is 6.1.0(not include 6.1.0). That is, gcc 4.8.1 to 5.x. The command g++ -dM -E -x c++ /dev/null | grep __cplusplus can be secondary verification.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We have a function for this in framework, better use this?

Either get_gcc_version, or get_tool_version('g++') (both from easybuild.tools.systemtools`)

I will try this. Thank you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lijiebio Thanks for the extra changes!

I included some minor code cleanup in cdb5eb7, should be good to go now as long as tests don't reveal any unexpected problems.

Beware that you're going into uncharted territory with doing builds in an old & unsupported OS like CentOS 7, you'll likely run into more problems because of this, mainly with installations that involve the system toolchain and hence system compiler, but potentially also because of the old glibc version...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One concrete example that you'll hit with the soon to be released EasyBuild v5.1.0: easybuilders/easybuild-easyconfigs#22798

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the reminder.

Comment thread easybuild/easyblocks/b/binutils.py Outdated
and self.toolchain.comp_family() == toolchain.SYSTEM
):
res = run_shell_cmd('g++ --version')
gxx_version = res.output.strip().split(' ')[2]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have a function for this in framework, better use this?

Either get_gcc_version, or get_tool_version('g++') (both from easybuild.tools.systemtools`)

@boegel boegel added this to the release after 5.1.0 milestone May 23, 2025
@boegel boegel added the bug fix label May 23, 2025
@lijiebio lijiebio requested a review from boegel May 23, 2025 09:28
@boegel boegel changed the title fix(binutils 2.42+): add buildopts CXXFLAGS="-std=c++11" for SYSTEM GCC 4.8.1 to 5.x add -std=c++11 to $CXXFLAGS when building binutils 2.42+ with system GCC 4.8.1 to 5.x May 23, 2025
@boegel
Copy link
Copy Markdown
Member

boegel commented May 23, 2025

@boegelbot please test @ jsc-zen3
EB_ARGS="binutils-2.32.eb binutils-2.38.eb binutils-2.42.eb binutils-2.44.eb binutils-2.37-GCCcore-11.2.0.eb binutils-2.42-GCCcore-13.3.0.eb --installpath /tmp/$USER/pr3728"
CORE_CNT=16

@boegelbot
Copy link
Copy Markdown

@boegel: Request for testing this PR well received on jsczen3l1.int.jsc-zen3.fz-juelich.de

PR test command 'if [[ develop != 'develop' ]]; then EB_BRANCH=develop ./easybuild_develop.sh 2> /dev/null 1>&2; EB_PREFIX=/home/boegelbot/easybuild/develop source init_env_easybuild_develop.sh; fi; EB_PR=3728 EB_ARGS="binutils-2.32.eb binutils-2.38.eb binutils-2.42.eb binutils-2.44.eb binutils-2.37-GCCcore-11.2.0.eb binutils-2.42-GCCcore-13.3.0.eb --installpath /tmp/$USER/pr3728" EB_REPO=easybuild-easyblocks EB_BRANCH=develop /opt/software/slurm/bin/sbatch --job-name test_PR_3728 --ntasks="16" ~/boegelbot/eb_from_pr_upload_jsc-zen3.sh' executed!

  • exit code: 0
  • output:
Submitted batch job 6454

Test results coming soon (I hope)...

Details

- notification for comment with ID 2904513281 processed

Message to humans: this is just bookkeeping information for me,
it is of no use to you (unless you think I have a bug, which I don't).

@boegelbot
Copy link
Copy Markdown

Test report by @boegelbot

Overview of tested easyconfigs (in order)

  • SUCCESS binutils-2.32.eb
  • SUCCESS binutils-2.38.eb
  • SUCCESS binutils-2.42.eb
  • SUCCESS binutils-2.44.eb
  • SUCCESS binutils-2.37-GCCcore-11.2.0.eb
  • SUCCESS binutils-2.42-GCCcore-13.3.0.eb

Build succeeded for 6 out of 6 (6 easyconfigs in total)
jsczen3c2.int.jsc-zen3.fz-juelich.de - Linux Rocky Linux 9.5, x86_64, AMD EPYC-Milan Processor (zen3), Python 3.9.21
See https://gist.github.com/boegelbot/e5ad41d67c6b7efe608420c8e9a8c740 for a full test report.

@boegel
Copy link
Copy Markdown
Member

boegel commented May 23, 2025

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS binutils-2.32.eb
  • SUCCESS binutils-2.38.eb
  • SUCCESS binutils-2.42.eb
  • SUCCESS binutils-2.44.eb
  • SUCCESS binutils-2.37-GCCcore-11.2.0.eb
  • SUCCESS binutils-2.42-GCCcore-13.3.0.eb

Build succeeded for 6 out of 6 (6 easyconfigs in total)
node4221.shinx.os - Linux RHEL 9.4, x86_64, AMD EPYC 9654 96-Core Processor (zen4), Python 3.9.18
See https://gist.github.com/boegel/faf99dd956810307c7ebf2983f6f2193 for a full test report.

@boegel
Copy link
Copy Markdown
Member

boegel commented May 23, 2025

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS binutils-2.32.eb
  • SUCCESS binutils-2.38.eb
  • SUCCESS binutils-2.42.eb
  • SUCCESS binutils-2.44.eb

Build succeeded for 4 out of 4 (4 easyconfigs in total)
node3502.doduo.os - Linux CentOS Linux 7.9.2009, x86_64, AMD EPYC 7552 48-Core Processor (zen2), Python 3.6.8
See https://gist.github.com/boegel/fa413e7084636d79bc08748e6dca9ad5 for a full test report.

@boegel boegel merged commit d5ddd56 into easybuilders:develop May 23, 2025
17 checks passed
@boegel
Copy link
Copy Markdown
Member

boegel commented May 23, 2025

@lijiebio Thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants