Skip to content

Commit

Permalink
Better handle LTO_ENABLE (qmk#9832)
Browse files Browse the repository at this point in the history
* Better handle LTO_ENABLE

Especially when calling from command line

* Replace LINK_TIME_OPTIMIZATION_ENABLE with LTO_ENABLE

* Remove long for LTO from show_options.mk
  • Loading branch information
drashna authored and noroadsleft committed Aug 29, 2020
1 parent 88dfe77 commit 3d3dddf
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 25 deletions.
4 changes: 1 addition & 3 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,9 @@ This is a [make](https://www.gnu.org/software/make/manual/make.html) file that i
```
* `LAYOUTS`
* A list of [layouts](feature_layouts.md) this keyboard supports.
* `LINK_TIME_OPTIMIZATION_ENABLE`
* `LTO_ENABLE`
* Enables Link Time Optimization (LTO) when compiling the keyboard. This makes the process take longer, but it can significantly reduce the compiled size (and since the firmware is small, the added time is not noticeable).
However, this will automatically disable the legacy TMK Macros and Functions features, as these break when LTO is enabled. It does this by automatically defining `NO_ACTION_MACRO` and `NO_ACTION_FUNCTION`. (Note: This does not affect QMK [Macros](feature_macros.md) and [Layers](feature_layers.md).)
* `LTO_ENABLE`
* Has the same meaning as `LINK_TIME_OPTIMIZATION_ENABLE`. You can use `LTO_ENABLE` instead of `LINK_TIME_OPTIMIZATION_ENABLE`.
## AVR MCU Options
* `MCU = atmega32u4`
Expand Down
4 changes: 1 addition & 3 deletions docs/ja/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,9 @@ QMK での全ての利用可能な設定にはデフォルトがあります。
```
* `LAYOUTS`
* このキーボードがサポートする[レイアウト](ja/feature_layouts.md)のリスト
* `LINK_TIME_OPTIMIZATION_ENABLE`
* `LTO_ENABLE`
* キーボードをコンパイルする時に、Link Time Optimization (LTO) を有効にします。これは処理に時間が掛かりますが、コンパイルされたサイズを大幅に減らします (そして、ファームウェアが小さいため、追加の時間は分からないくらいです)。
ただし、LTO が有効な場合、古い TMK のマクロと関数の機能が壊れるため、自動的にこれらの機能を無効にします。これは `NO_ACTION_MACRO` と `NO_ACTION_FUNCTION` を自動的に定義することで行われます。(メモ: これは QMK の [マクロ](ja/feature_macros.md) と [レイヤー](ja/feature_layers.md) には影響を与えません。)
* `LTO_ENABLE`
* LINK_TIME_OPTIMIZATION_ENABLE と同じ意味です。`LINK_TIME_OPTIMIZATION_ENABLE` の代わりに `LTO_ENABLE` を使うことができます。
## AVR MCU オプション
* `MCU = atmega32u4`
Expand Down
3 changes: 1 addition & 2 deletions show_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ OTHER_OPTION_NAMES = \
RGB_MATRIX_KEYPRESSES \
LED_MIRRORED \
RGBLIGHT_FULL_POWER \
Link_Time_Optimization \
LINK_TIME_OPTIMIZATION_ENABLE
LTO_ENABLE

define NAME_ECHO
@echo " $1 = $($1) # $(origin $1)"
Expand Down
9 changes: 3 additions & 6 deletions tmk_core/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,13 @@ ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
endif

ifeq ($(strip $(LTO_ENABLE)), yes)
LINK_TIME_OPTIMIZATION_ENABLE = yes
endif

ifeq ($(strip $(LINK_TIME_OPTIMIZATION_ENABLE)), yes)
ifeq ($(PLATFORM),CHIBIOS)
$(info Enabling LTO on ChibiOS-targeting boards is known to have a high likelihood of failure.)
$(info If unsure, set LINK_TIME_OPTIMIZATION_ENABLE = no.)
$(info If unsure, set LTO_ENABLE = no.)
endif
EXTRAFLAGS += -flto
TMK_COMMON_DEFS += -DLINK_TIME_OPTIMIZATION_ENABLE
TMK_COMMON_DEFS += -DLTO_ENABLE
TMK_COMMON_DEFS += -DLINK_TIME_OPTIMIZATON_ENABLE
endif

# Search Path
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/common/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
#endif

/* Disable macro and function features when LTO is enabled, since they break */
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
#ifdef LTO_ENABLE
# ifndef NO_ACTION_MACRO
# define NO_ACTION_MACRO
# endif
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/common/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static void print_version(void) {
#ifdef NKRO_ENABLE
" NKRO"
#endif
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
#ifdef LTO_ENABLE
" LTO"
#endif

Expand Down
2 changes: 1 addition & 1 deletion users/bcat/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EXTRAKEY_ENABLE = yes
NKRO_ENABLE = yes

# Enable link-time optimization to reduce binary size.
LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes

# Disable unused build options on all keyboards.
COMMAND_ENABLE = no
Expand Down
3 changes: 1 addition & 2 deletions users/dshields/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPACE_CADET_ENABLE = no
LEADER_ENABLE = no
DYNAMIC_MACRO_ENABLE = yes

LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes

ifeq ($(strip $(KEYBOARD)), planck/rev3)
AUDIO_ENABLE = no
Expand All @@ -29,4 +29,3 @@ ifeq ($(strip $(KEYBOARD)), planck/light)
BACKLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes
endif

2 changes: 1 addition & 1 deletion users/issmirnov/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SRC += issmirnov.c

# https://www.reddit.com/r/olkb/comments/bmpgjm/programming_help/
# Should shave 2000 bytes
LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes

# Enable debugging only when needed.
CONSOLE_ENABLE = yes # +400 bytes (hid_listen support)
Expand Down
4 changes: 2 additions & 2 deletions users/kuchosauronad0/rules.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SRC += kuchosauronad0.c \
process_records.c

LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes
SPACE_CADET_ENABLE = no

ifneq ($(strip $(RGBLIGHT_ENABLE)),yes )
Expand All @@ -24,7 +24,7 @@ ifeq ($(strip $(LEADER_ENABLE)), yes)
SRC += leader.c
endif

ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
SRC += secrets.c
endif
ifeq ($(strip $(NO_SECRETS)), yes)
Expand Down
2 changes: 1 addition & 1 deletion users/pvinis/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ SRC += pvinis.c # add userspace file

## Some extra stuff to make firmware smaller.

# LINK_TIME_OPTIMIZATION_ENABLE = yes
# LTO_ENABLE = yes
# CONSOLE_ENABLE = no
# COMMAND_ENABLE = no
2 changes: 1 addition & 1 deletion users/yanfali/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BOOTMAGIC = lite
DYNAMIC_KEYMAP_ENABLE = no
CONSOLE_ENABLE = yes
COMMAND_ENABLE = yes
LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes
AUDIO_ENABLE = no

# only enable audio on specific boards
Expand Down
2 changes: 1 addition & 1 deletion users/yet-another-developer/rules.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SRC += yet-another-developer.c \
process_records.c

LINK_TIME_OPTIMIZATION_ENABLE = yes
LTO_ENABLE = yes
SPACE_CADET_ENABLE = no

ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
Expand Down

0 comments on commit 3d3dddf

Please sign in to comment.