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

Add option to enable LTO easily #5674

Merged
merged 3 commits into from
May 2, 2019
Merged

Conversation

drashna
Copy link
Member

@drashna drashna commented Apr 21, 2019

and disable features that cause compilation errors when LTO is enabled.

Added to tmk_core/common.mk rather than common_features.mk, since it's not really a feature.

Copy link
Contributor

@yanfali yanfali left a comment

Choose a reason for hiding this comment

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

Maybe add a warning about what you are disabling

@drashna
Copy link
Member Author

drashna commented Apr 21, 2019

I should probably add docs for this too....
That would be a better place for the warnings.

@mtei
Copy link
Contributor

mtei commented Apr 21, 2019

Previously, the advice you gave was to add #define DISABLE_LEADER to config.h. Is this not necessary now?

#3546 (comment)

@drashna
Copy link
Member Author

drashna commented Apr 21, 2019

Previously, the advice you gave was to add #define DISABLE_LEADER to config.h. Is this not necessary now?

At the time, it was true. However, it's since been moved into it's own "feature" that is off by default, and only enabled if you add LEADER_ENABLE=yes to the makefile settings.

Also, the only reason I have it turning off the macros and functions is that enabling LTO can/will break those features.

@mtei
Copy link
Contributor

mtei commented Apr 21, 2019

I see.

FYI, there are also the following ways.

tmk_core/common.mk:

ifeq ($(strip $(LINK_TIME_OPTIMIZATION_ENABLE)), yes)
	    EXTRAFLAGS += -flto
	    POST_CONFIG_H += $(TMK_DIR)/post_config.h
	    TMK_COMMON_DEFS += -DLINK_TIME_OPTIMIZATION_ENABLE
endif

tmk_core/post_config.h:

#pragma once
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
  #define NO_ACTION_MACRO
  #define NO_ACTION_FUNCTION
  #ifdef LEADER_ENABLE
    #error  some error message
  #endif
#endif

@drashna
Copy link
Member Author

drashna commented Apr 21, 2019

@mtei That would definitely work. But there is no reason to disable Leader Keys here. In fact, I think doing so is a bad idea, actually. I think that we should use the "lightest touch" here, and not disable anything, unless it's needed (aka it's breaking something).

@mtei
Copy link
Contributor

mtei commented Apr 21, 2019

OK, you are right. I do not know the relationship between LTO and LEADER_ENABLE. Just simply, if you need collision detection, just let you know that there is a way.

@vomindoraan
Copy link
Contributor

Consider LTO_ENABLE instead of LINK_TIME_OPTIMIZATION_ENABLE.

@mtei
Copy link
Contributor

mtei commented Apr 25, 2019

ifeq ($(filter $(LTO_ENABLE) $(LINK_TIME_OPTIMIZATION_ENABLE),yes), yes)

Copy link
Contributor

@mechmerlin mechmerlin left a comment

Choose a reason for hiding this comment

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

Thanks!

@mechmerlin mechmerlin merged commit 7e655a2 into qmk:master May 2, 2019
@drashna drashna deleted the feature/lto_flag branch May 2, 2019 15:58
drashna added a commit to zsa/qmk_firmware that referenced this pull request May 6, 2019
* Add option to enable LTO easily and disable features that cause compiling errors with LTO

* Add documentation about LTO option

* Add to show_options
fdidron added a commit to zsa/qmk_firmware that referenced this pull request May 6, 2019
Add option to enable LTO easily  (qmk#5674)
foosinn pushed a commit to foosinn/qmk_firmware that referenced this pull request May 6, 2019
* Add option to enable LTO easily and disable features that cause compiling errors with LTO

* Add documentation about LTO option

* Add to show_options
Timbus pushed a commit to Timbus/qmk_firmware that referenced this pull request Jun 23, 2019
* Add option to enable LTO easily and disable features that cause compiling errors with LTO

* Add documentation about LTO option

* Add to show_options
ridingqwerty pushed a commit to ridingqwerty/qmk_firmware that referenced this pull request Jan 10, 2020
* Add option to enable LTO easily and disable features that cause compiling errors with LTO

* Add documentation about LTO option

* Add to show_options
JeffreyPalmer pushed a commit to JeffreyPalmer/qmk_firmware that referenced this pull request Feb 27, 2020
* Add option to enable LTO easily and disable features that cause compiling errors with LTO

* Add documentation about LTO option

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

Successfully merging this pull request may close these issues.

None yet

5 participants