Skip to content

Commit 3d3dddf

Browse files
drashnanoroadsleft
authored andcommitted
Better handle LTO_ENABLE (qmk#9832)
* 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
1 parent 88dfe77 commit 3d3dddf

File tree

13 files changed

+16
-25
lines changed

13 files changed

+16
-25
lines changed

docs/config_options.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,9 @@ This is a [make](https://www.gnu.org/software/make/manual/make.html) file that i
324324
```
325325
* `LAYOUTS`
326326
* A list of [layouts](feature_layouts.md) this keyboard supports.
327-
* `LINK_TIME_OPTIMIZATION_ENABLE`
327+
* `LTO_ENABLE`
328328
* 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).
329329
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).)
330-
* `LTO_ENABLE`
331-
* Has the same meaning as `LINK_TIME_OPTIMIZATION_ENABLE`. You can use `LTO_ENABLE` instead of `LINK_TIME_OPTIMIZATION_ENABLE`.
332330
333331
## AVR MCU Options
334332
* `MCU = atmega32u4`

docs/ja/config_options.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,9 @@ QMK での全ての利用可能な設定にはデフォルトがあります。
322322
```
323323
* `LAYOUTS`
324324
* このキーボードがサポートする[レイアウト](ja/feature_layouts.md)のリスト
325-
* `LINK_TIME_OPTIMIZATION_ENABLE`
325+
* `LTO_ENABLE`
326326
* キーボードをコンパイルする時に、Link Time Optimization (LTO) を有効にします。これは処理に時間が掛かりますが、コンパイルされたサイズを大幅に減らします (そして、ファームウェアが小さいため、追加の時間は分からないくらいです)。
327327
ただし、LTO が有効な場合、古い TMK のマクロと関数の機能が壊れるため、自動的にこれらの機能を無効にします。これは `NO_ACTION_MACRO` と `NO_ACTION_FUNCTION` を自動的に定義することで行われます。(メモ: これは QMK の [マクロ](ja/feature_macros.md) と [レイヤー](ja/feature_layers.md) には影響を与えません。)
328-
* `LTO_ENABLE`
329-
* LINK_TIME_OPTIMIZATION_ENABLE と同じ意味です。`LINK_TIME_OPTIMIZATION_ENABLE` の代わりに `LTO_ENABLE` を使うことができます。
330328
331329
## AVR MCU オプション
332330
* `MCU = atmega32u4`

show_options.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ OTHER_OPTION_NAMES = \
8282
RGB_MATRIX_KEYPRESSES \
8383
LED_MIRRORED \
8484
RGBLIGHT_FULL_POWER \
85-
Link_Time_Optimization \
86-
LINK_TIME_OPTIMIZATION_ENABLE
85+
LTO_ENABLE
8786

8887
define NAME_ECHO
8988
@echo " $1 = $($1) # $(origin $1)"

tmk_core/common.mk

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,13 @@ ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
160160
endif
161161

162162
ifeq ($(strip $(LTO_ENABLE)), yes)
163-
LINK_TIME_OPTIMIZATION_ENABLE = yes
164-
endif
165-
166-
ifeq ($(strip $(LINK_TIME_OPTIMIZATION_ENABLE)), yes)
167163
ifeq ($(PLATFORM),CHIBIOS)
168164
$(info Enabling LTO on ChibiOS-targeting boards is known to have a high likelihood of failure.)
169-
$(info If unsure, set LINK_TIME_OPTIMIZATION_ENABLE = no.)
165+
$(info If unsure, set LTO_ENABLE = no.)
170166
endif
171167
EXTRAFLAGS += -flto
172-
TMK_COMMON_DEFS += -DLINK_TIME_OPTIMIZATION_ENABLE
168+
TMK_COMMON_DEFS += -DLTO_ENABLE
169+
TMK_COMMON_DEFS += -DLINK_TIME_OPTIMIZATON_ENABLE
173170
endif
174171

175172
# Search Path

tmk_core/common/action.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
#endif
3030

3131
/* Disable macro and function features when LTO is enabled, since they break */
32-
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
32+
#ifdef LTO_ENABLE
3333
# ifndef NO_ACTION_MACRO
3434
# define NO_ACTION_MACRO
3535
# endif

tmk_core/common/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void print_version(void) {
180180
#ifdef NKRO_ENABLE
181181
" NKRO"
182182
#endif
183-
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
183+
#ifdef LTO_ENABLE
184184
" LTO"
185185
#endif
186186

users/bcat/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ EXTRAKEY_ENABLE = yes
1414
NKRO_ENABLE = yes
1515

1616
# Enable link-time optimization to reduce binary size.
17-
LINK_TIME_OPTIMIZATION_ENABLE = yes
17+
LTO_ENABLE = yes
1818

1919
# Disable unused build options on all keyboards.
2020
COMMAND_ENABLE = no

users/dshields/rules.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SPACE_CADET_ENABLE = no
1010
LEADER_ENABLE = no
1111
DYNAMIC_MACRO_ENABLE = yes
1212

13-
LINK_TIME_OPTIMIZATION_ENABLE = yes
13+
LTO_ENABLE = yes
1414

1515
ifeq ($(strip $(KEYBOARD)), planck/rev3)
1616
AUDIO_ENABLE = no
@@ -29,4 +29,3 @@ ifeq ($(strip $(KEYBOARD)), planck/light)
2929
BACKLIGHT_ENABLE = no
3030
RGB_MATRIX_ENABLE = yes
3131
endif
32-

users/issmirnov/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SRC += issmirnov.c
44

55
# https://www.reddit.com/r/olkb/comments/bmpgjm/programming_help/
66
# Should shave 2000 bytes
7-
LINK_TIME_OPTIMIZATION_ENABLE = yes
7+
LTO_ENABLE = yes
88

99
# Enable debugging only when needed.
1010
CONSOLE_ENABLE = yes # +400 bytes (hid_listen support)

users/kuchosauronad0/rules.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SRC += kuchosauronad0.c \
22
process_records.c
33

4-
LINK_TIME_OPTIMIZATION_ENABLE = yes
4+
LTO_ENABLE = yes
55
SPACE_CADET_ENABLE = no
66

77
ifneq ($(strip $(RGBLIGHT_ENABLE)),yes )
@@ -24,7 +24,7 @@ ifeq ($(strip $(LEADER_ENABLE)), yes)
2424
SRC += leader.c
2525
endif
2626

27-
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
27+
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
2828
SRC += secrets.c
2929
endif
3030
ifeq ($(strip $(NO_SECRETS)), yes)

users/pvinis/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ SRC += pvinis.c # add userspace file
1414

1515
## Some extra stuff to make firmware smaller.
1616

17-
# LINK_TIME_OPTIMIZATION_ENABLE = yes
17+
# LTO_ENABLE = yes
1818
# CONSOLE_ENABLE = no
1919
# COMMAND_ENABLE = no

users/yanfali/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BOOTMAGIC = lite
22
DYNAMIC_KEYMAP_ENABLE = no
33
CONSOLE_ENABLE = yes
44
COMMAND_ENABLE = yes
5-
LINK_TIME_OPTIMIZATION_ENABLE = yes
5+
LTO_ENABLE = yes
66
AUDIO_ENABLE = no
77

88
# only enable audio on specific boards

users/yet-another-developer/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SRC += yet-another-developer.c \
22
process_records.c
33

4-
LINK_TIME_OPTIMIZATION_ENABLE = yes
4+
LTO_ENABLE = yes
55
SPACE_CADET_ENABLE = no
66

77
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)

0 commit comments

Comments
 (0)