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

Makefile: Better respect CFLAGS and CXXFLAGS as environment variables. #7772

Merged
merged 1 commit into from
Jan 5, 2019

Conversation

orbea
Copy link
Contributor

@orbea orbea commented Dec 19, 2018

Please wait for travis, I only tested the qb build system.

Description

This fixes a few subtle problems with passing CFLAGS and CXXFLAGS as environment variables for configure.

First it will now only add these variables to config.mk when they are actually set. If they are unset then the default optimizations in the Makefile are set. This avoids passing more than one conflicting optimization level to the compiler.

Next all CFLAGS are added to CXXFLAGS to avoid issues with forgetting to set both CFLAGS and CXXFLAGS. This results in the cxx compiler getting passed several redundant optimization levels when both the CFLAGS and CXXFLAGS environment variabls are used. Now these uses of CFLAGS in Makefile.common are set to DEF_FLAGS. This allows adding $(DEF_FLAGS) to the CXXFLAGS variable without adding redundant flags from CFLAGS.

@orbea
Copy link
Contributor Author

orbea commented Dec 19, 2018

Actually, I think I still need to hook up other Makefiles that include Makefile.common which travis will not test, I'll do that in a little bit.

@orbea
Copy link
Contributor Author

orbea commented Dec 19, 2018

I updated the other Makefiles and force pushed the changes. I think they should have no change in behavior now, but I am not in a position to test them personally.

@orbea orbea requested a review from a user December 19, 2018 20:22
@orbea
Copy link
Contributor Author

orbea commented Dec 19, 2018

One extra benefit of this is that it will allow the user to compile C and C++ code with different compile flags.

@inactive123
Copy link
Contributor

Is this PR ready now?

@orbea
Copy link
Contributor Author

orbea commented Dec 20, 2018

It should be, but it would be nice if someone can take a look at other Makefiles and make sure I didn't do something wrong. Unfortunately travis doesn't test them yet...

@orbea
Copy link
Contributor Author

orbea commented Dec 21, 2018

@bparker06 When you have a chance can you take a look at this PR and see if you see anything wrong? This issue has been bugging me for a while, but given how Makefile.common is used in so many places it was hard to fix...

This fixes a few subtle problems with passing CFLAGS and CXXFLAGS as
environment variables for configure.

First it will now only add these variables to config.mk when they are
actually set. If they are unset then the default optimizations in the
Makefile are set. This avoids passing more than one conflicting
optimization level to the compiler.

Next all CFLAGS are added to CXXFLAGS to avoid issues with forgetting to
set both CFLAGS and CXXFLAGS. This results in the cxx compiler getting
passed several redundant optimization levels when both the CFLAGS and
CXXFLAGS environment variabls are used. Now these uses of CFLAGS in
Makefile.common are set to DEF_FLAGS. This allows adding $(DEF_FLAGS)
to the CXXFLAGS variable without adding redundant flags from CFLAGS.

v2: Update other build files.
@orbea
Copy link
Contributor Author

orbea commented Dec 31, 2018

Conflict fixed.

@orbea
Copy link
Contributor Author

orbea commented Jan 3, 2019

@fjtrujy Since you seem able of testing a lot of platforms would mind testing this PR and make sure everything still builds right? :)

@inactive123 inactive123 merged commit e827c36 into libretro:master Jan 5, 2019
@orbea orbea deleted the opt branch January 5, 2019 17:09
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.

2 participants