From: Christian Lamparter Date: Sun, 19 Aug 2012 18:30:59 +0000 (+0200) Subject: carl9170: link time optimization build X-Git-Tag: 1.9.7~29 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1a2fbaf4f621cbb37f36637b1d4101f453474f7a;p=carl9170fw.git carl9170: link time optimization build Enabling LTO will hopefully lead to smaller firmware binaries and maybe even slightly better performance. Signed-off-by: Christian Lamparter --- diff --git a/carlfw/CMakeLists.txt b/carlfw/CMakeLists.txt index caf9595..81b1346 100644 --- a/carlfw/CMakeLists.txt +++ b/carlfw/CMakeLists.txt @@ -5,12 +5,14 @@ project(carl9170.fw) include("../extra/sh-elf-linux.cmake") include("../config.cmake") +set(CARL9170_FW_ELF carl9170.elf) set(CARLFW_CFLAGS_WARNING "-W -Wall -Wextra -Wunreachable-code -Winline -Wlogical-op -Wno-packed-bitfield-compat -Winit-self -Wshadow -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wformat=2 -Wcast-align -Wmissing-format-attribute -Wmissing-prototypes -Wtype-limits -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wdisabled-optimization -Wpointer-arith -Wvolatile-register-var -Waddress -Wbad-function-cast -Wunsafe-loop-optimizations") set(CARLFW_CFLAGS_EXTRA "-mbitops -std=gnu99 -ffunction-sections -Wframe-larger-than=128 -Werror") set(CARLFW_CFLAGS_DEF "-D__CARL9170FW__") if (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS) - set(CARLFW_CFLAGS_AGGRESSIVE "-fomit-frame-pointer -fsee -frename-registers -ftree-vectorize -flto -fstrict-volatile-bitfields -fmodulo-sched") + set(CARLFW_CFLAGS_AGGRESSIVE "-fomit-frame-pointer -fsee -frename-registers -ftree-vectorize -flto -fstrict-volatile-bitfields -fmodulo-sched -fwhole-program") endif (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS) +set(CARLFW_CFLAGS "${CARLFW_CFLAGS_DEF} ${CARLFW_CFLAGS_EXTRA} ${CARLFW_CFLAGS_AGGRESSIVE} ${CARLFW_CFLAGS_WARNING}") include_directories (../include/linux ../include/shared ../include include) @@ -33,11 +35,8 @@ add_executable(carl9170.elf ${carl9170_src}) set_target_properties(carl9170.elf PROPERTIES LINKER_LANGUAGE C) -set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS - " ${CARLFW_CFLAGS_DEF} ${CARLFW_CFLAGS_EXTRA} ${CARLFW_CFLAGS_AGGRESSIVE} ${CARLFW_CFLAGS_WARNING}") -set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "-Tcarl9170.lds") - - +set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}") +set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds") add_custom_target(firmware ALL) diff --git a/carlfw/src/fw.c b/carlfw/src/fw.c index 5bde675..8f0b33e 100644 --- a/carlfw/src/fw.c +++ b/carlfw/src/fw.c @@ -31,7 +31,7 @@ more \ } -const struct carl9170_firmware_descriptor __section(fwdsc) carl9170fw_desc = { +const struct carl9170_firmware_descriptor __section(fwdsc) __visible carl9170fw_desc = { FILL(otus, OTUS, .feature_set = cpu_to_le32(BIT(CARL9170FW_DUMMY_FEATURE) | BIT(CARL9170FW_USB_RESP_EP2) | diff --git a/carlfw/src/main.c b/carlfw/src/main.c index 17cbaf9..80e7e21 100644 --- a/carlfw/src/main.c +++ b/carlfw/src/main.c @@ -217,7 +217,7 @@ static void __noreturn main_loop(void) * we put _start() there with the linker script carl9170.lds. */ -void __section(boot) start(void) +void __section(boot) __noreturn __visible start(void) { clock_set(AHB_40MHZ_OSC, true); diff --git a/carlfw/src/udivsi3_i4i-Os.S b/carlfw/src/udivsi3_i4i-Os.S index 7bbec4c..191bf2e 100644 --- a/carlfw/src/udivsi3_i4i-Os.S +++ b/carlfw/src/udivsi3_i4i-Os.S @@ -42,8 +42,6 @@ Boston, MA 02110-1301, USA. */ .global ___udivsi3_i4i .global ___udivsi3_i4 .set ___udivsi3_i4, ___udivsi3_i4i - .type ___udivsi3_i4i, @function - .type ___sdivsi3_i4i, @function ___udivsi3_i4i: sts pr,r1 mov.l r4,@-r15 diff --git a/extra/sh-elf-linux.cmake b/extra/sh-elf-linux.cmake index 8be6d36..2429436 100644 --- a/extra/sh-elf-linux.cmake +++ b/extra/sh-elf-linux.cmake @@ -6,7 +6,7 @@ set_property(DIRECTORY PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SOURCE_DIR}/toolchain/inst/) set(CMAKE_C_FLAGS "-m2 -ml -Os -ffreestanding -nostartfiles") -set(CMAKE_C_LINK_FLAGS "-static -EL -x --gc-sections") +set(CMAKE_C_LINK_FLAGS "-Wl,-static,-EL,-x,--gc-sections") set(OBJCOPY ${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-objcopy) set(CMAKE_C_COMPILER "${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-gcc") @@ -14,7 +14,7 @@ set(CMAKE_AR ${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-ar) set(CMAKE_ASM_COMPILER ${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-as) set(CMAKE_ASM-ATT_COMPILER ${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-as) set(CMAKE_LINKER ${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-ld) -set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-ld -o ") +set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-gcc ${CMAKE_C_FLAGS} -o ") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index d331f3c..b81bf14 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -27,6 +27,7 @@ #define __section(s) __attribute__((section("." # s))) #define __aligned(a) __attribute__((aligned(a))) #define __packed __attribute__((packed)) +#define __visible __attribute__((externally_visible)) #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)