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

´Use g++ and clang++ instead of gcc and clang as C++ compilers #4234

Merged
merged 7 commits into from
Feb 26, 2024

Conversation

RCoeurjoly
Copy link
Contributor

This would solve the CXX and LD points of #2011.
LD is also changed to g++ when appropriate.

All pipelines pass in my fork (https://github.com/RCoeurjoly/yosys/actions).

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

clang++ is not a linker, it is a compiler driver, so it should not be used in the $(LD) variable. Either put a linker (ld, lld, etc) in $(LD) or remove $(LD) altogether and change $(LDFLAGS) to $(LINKFLAGS) or something.

@RCoeurjoly
Copy link
Contributor Author

It seems that clang++ or g++ can be used as the linker, specially if sanitizers are used: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#usage.

I think it is not viable to use ld, because -rdynamic is supported in g++ and clang++ and not in ld, if I am not mistaken.
When I set LD = ld or remove $LD, I get the following error:
ld: unrecognised option: -rdynamic

@whitequark
Copy link
Member

I think it is not viable to use ld

That is possible. In that case you should remove $(LD) entirely and use $(CXX) instead to link.

@RCoeurjoly
Copy link
Contributor Author

I think it is not viable to use ld

That is possible. In that case you should remove $(LD) entirely and use $(CXX) instead to link.

Done. I had to change $LD for $CXX in passes/techmap/Makefile.inc, otherwise we would get the same linking error

ld: unrecognised option: -rdynamic

@whitequark
Copy link
Member

whitequark commented Feb 25, 2024

Looks better, thank you. Now that we don't have $(LD), we should not use $(LDFLAGS) either; I propose $(LINKFLAGS). Similarly, instead of $(LDLIBS) we can use $(LIBS).

It looks like we have a bunch of $(filter-out -rdynamic) clauses that can probably be simplified by not adding -rdynamic by default in first place, but I'll take another look at that later, and it doesn't strictly speaking have to be a part of this PR.

@RCoeurjoly
Copy link
Contributor Author

Looks better, thank you. Now that we don't have $(LD), we should not use $(LDFLAGS) either; I propose $(LINKFLAGS). Similarly, instead of $(LDLIBS) we can use $(LIBS).

It looks like we have a bunch of $(filter-out -rdynamic) clauses that can probably be simplified by not adding -rdynamic by default in first place, but I'll take another look at that later, and it doesn't strictly speaking have to be a part of this PR.

Done. I had to fix it in other Makefiles too.

Now two tests fail

I have reproduced the error locally by running:
cd tests/various
bash run-test.sh

I get the following error:

make: *** [run-test.mk:456: async.sh] Error 127

I am a bit lost as to how to debug that failure.

@povik
Copy link
Member

povik commented Feb 25, 2024

Now two tests fail

Those happen to be the only CI jobs which run the testsuite (through make test), the other CI jobs build the binaries but don't run make test.

Looks like the fault is in tests/various/plugin.sh because yosys-config needs updating, see misc/yosys-config.in.

Comment on lines 12 to 13
echo " --ldflags @LINKFLAGS@"
echo " --ldlibs @LIBS@"
Copy link
Member

Choose a reason for hiding this comment

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

I think we should rename them here as well, while providing compatibility:

Suggested change
echo " --ldflags @LINKFLAGS@"
echo " --ldlibs @LIBS@"
echo " --linkflags @LINKFLAGS@"
echo " --ldflags (alias of --linkflags)
echo " --linklibs @LIBS@"
echo " --ldlibs (alias of --linklibs)

CXXFLAGS = -MD -Wall -Wextra -ggdb
CXXFLAGS += -std=c++11 -O0
LDLIBS = ../minisat/Options.cc ../minisat/SimpSolver.cc ../minisat/Solver.cc ../minisat/System.cc -lm -lstdc++
LIBS = ../minisat/Options.cc ../minisat/SimpSolver.cc ../minisat/Solver.cc ../minisat/System.cc -lm -lstdc++
Copy link
Member

@whitequark whitequark Feb 26, 2024

Choose a reason for hiding this comment

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

This is a completely unhinged definition of LIBS.

(I am not asking you to fix it; I am just stating my bewilderment.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was surprised too.

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you a lot! The Makefiles are not perfect but they are at least not blatantly misleading anymore, so we are getting somewhere!!

@RCoeurjoly
Copy link
Contributor Author

Looks good to me, thank you a lot! The Makefiles are not perfect but they are at least not blatantly misleading anymore, so we are getting somewhere!!

Thank you for your patience and handholding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants