Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate -lgcc flags in linker command with GCC 13.2.0 on macOS #170310

Closed
4 tasks done
TahaAkhlaq opened this issue Apr 29, 2024 · 3 comments
Closed
4 tasks done

Duplicate -lgcc flags in linker command with GCC 13.2.0 on macOS #170310

TahaAkhlaq opened this issue Apr 29, 2024 · 3 comments
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age

Comments

@TahaAkhlaq
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

`brew config` Output: 
HOMEBREW_VERSION: 4.2.19
ORIGIN: https://github.com/Homebrew/brew
HEAD: 54bea636b41f7953c01a7da5f488f08c1b42ffd1
Last commit: 7 days ago
Core tap JSON: 29 Apr 04:13 UTC
Core cask tap JSON: 29 Apr 04:13 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_BROWSER: /Users/taha/.vscode-server/cli/servers/Stable-31c37ee8f63491495ac49e43b8544550fbae4533/server/bin/helpers/browser.sh
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: code --wait
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: octa-core 64-bit arm_blizzard_avalanche
Clang: 15.0.0 build 1500
Git: 2.44.0 => /opt/homebrew/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.3.1-arm64
CLT: 15.1.0.0.1.1700200546
Xcode: 15.3
Rosetta 2: false

`brew doctor` Output: 
Your system is ready to brew

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was trying to compile a simple C++ project using GCC installed via Homebrew on macOS. My goal was to use the latest GCC for my development work, but I encountered an issue with duplicate library flags during the linking phase, which I believe might be a configuration error or a bug.

What happened (include all command output)?

I am experiencing an issue where the ld linker command automatically includes the -lgcc library twice when compiling a C++ project using GCC 13.2.0 installed via Homebrew on macOS. This results in a warning about ignoring duplicate libraries, which I'd like to resolve or understand.

Command Used:
g++ project3.cpp -o project3

The linker command includes -lgcc twice, resulting in a warning:
ld: warning: ignoring duplicate libraries: '-lgcc'

Verbose output indicated that -lgcc is being linked twice in the linker command automatically generated by GCC.

Verbose Output
(Including a brief snippet of the verbose output where the duplicate -lgcc is evident)
.o -lstdc++ -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath

What did you expect to happen?

I expected the linker command not to include duplicate library flags, which should avoid the warning about ignoring duplicate libraries. Ideally, the build process should be clean without such warnings, ensuring that the linker configuration is optimal and error-free.

Step-by-step reproduction instructions (by running brew commands)

**Steps to Reproduce**
1. Install GCC via Homebrew using `brew install gcc`.
2. Compile any simple C++ program with `g++ [file].cpp -o [file]`.
3. Observe the linker warning about duplicate `-lgcc` flags.

Other:
**System Information**
- **macOS Version**: Sonoma (Version 14)
- **Homebrew Version**: Homebrew 4.2.19
- **GCC Version**: 13.2.0: g++-13 (Homebrew GCC 13.2.0) 13.2.0

**Additional Information**
- I have checked my environment settings and there are no configurations explicitly adding `-lgcc` multiple times.
- The issue seems to be internal to the way GCC is configured or how it interacts with the system linker.


Thank you for any help or insight you can provide!
@TahaAkhlaq TahaAkhlaq added the bug Reproducible Homebrew/homebrew-core bug label Apr 29, 2024
@ZhongRuoyu
Copy link
Member

Can you try updating your Command Line Tools? See also: https://github.com/orgs/Homebrew/discussions/4794

@TahaAkhlaq
Copy link
Author

Thank you for your response. The Command Line Tools are updated. Also, thank you for linking the discussion!

@fxcoudert
Copy link
Member

The warning is harmless, and the fix has been made upstream.

@github-actions github-actions bot added the outdated PR was locked due to age label Jun 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

3 participants