diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-05-07 17:02:40 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-05-15 14:02:04 -0400 |
commit | 233adfe66026a3968f50333d2a48c954356e9786 (patch) | |
tree | 95df2e3b1016619776f8d6f007c360d9d6fd640d | |
parent | 450c14b28631455ea61eb15bebe5579268b228ef (diff) | |
download | kutter-233adfe66026a3968f50333d2a48c954356e9786.tar.gz kutter-233adfe66026a3968f50333d2a48c954356e9786.tar.xz kutter-233adfe66026a3968f50333d2a48c954356e9786.zip |
build: Add __visible to variables in compile_time_request.c
Add __visible to generated code in compile_time_request.c so that the
main code can be compiled with -fwhole-program.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | scripts/buildcommands.py | 14 |
2 files changed, 9 insertions, 7 deletions
@@ -38,7 +38,7 @@ CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -O2 -MD -g \ CFLAGS += -flto -fwhole-program -fno-use-linker-plugin CFLAGS_klipper.o = $(CFLAGS) -Wl,-r -nostdlib -CFLAGS_klipper.elf = $(CFLAGS) -Wl,--gc-sections -fno-whole-program +CFLAGS_klipper.elf = $(CFLAGS) -Wl,--gc-sections CPPFLAGS = -I$(OUT) -P -MD -MT $@ diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py index c0584d15..a831f52b 100644 --- a/scripts/buildcommands.py +++ b/scripts/buildcommands.py @@ -15,6 +15,7 @@ FILEHEADER = """ #include "board/pgm.h" #include "command.h" +#include "compiler.h" """ def error(msg): @@ -68,7 +69,7 @@ def build_parsers(parsers, msg_to_id, all_param_types): parsercode = build_parser(parser, 0, all_param_types) pcode.append("{%s\n}, " % (parsercode,)) fmt = """ -const struct command_encoder command_encoders[] PROGMEM = { +const struct command_encoder command_encoders[] PROGMEM __visible = { %s }; """ @@ -101,7 +102,7 @@ def build_commands(cmd_by_id, messages_by_name, all_param_types): index.append(" &%s," % (parsername,)) parser = msgproto.MessageFormat(msgid, msg) parsercode = build_parser(parser, 1, all_param_types) - parsers.append("const struct command_parser %s PROGMEM = {" + parsers.append("const struct command_parser %s PROGMEM __visible = {" " %s\n .flags=%s,\n .func=%s\n};" % ( parsername, parsercode, flags, funcname)) index = "\n".join(index) @@ -112,11 +113,11 @@ def build_commands(cmd_by_id, messages_by_name, all_param_types): %s -const struct command_parser * const command_index[] PROGMEM = { +const struct command_parser * const command_index[] PROGMEM __visible = { %s }; -const uint8_t command_index_size PROGMEM = ARRAY_SIZE(command_index); +const uint8_t command_index_size PROGMEM __visible = ARRAY_SIZE(command_index); """ return fmt % (externs, '\n'.join(parsers), index) @@ -146,11 +147,12 @@ def build_identify(cmd_by_id, msg_to_id, responses, static_strings out.append('\n ') out.append(" 0x%02x," % (ord(zdata[i]),)) fmt = """ -const uint8_t command_identify_data[] PROGMEM = {%s +const uint8_t command_identify_data[] PROGMEM __visible = {%s }; // Identify size = %d (%d uncompressed) -const uint32_t command_identify_size PROGMEM = ARRAY_SIZE(command_identify_data); +const uint32_t command_identify_size PROGMEM __visible + = ARRAY_SIZE(command_identify_data); """ return data, fmt % (''.join(out), len(zdata), len(data)) |