carl9170: link time optimization build
authorChristian Lamparter <chunkeey@googlemail.com>
Sun, 19 Aug 2012 18:30:59 +0000 (20:30 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Sun, 19 Aug 2012 18:59:35 +0000 (20:59 +0200)
Enabling LTO will hopefully lead to smaller
firmware binaries and maybe even slightly
better performance.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
carlfw/CMakeLists.txt
carlfw/src/fw.c
carlfw/src/main.c
carlfw/src/udivsi3_i4i-Os.S
extra/sh-elf-linux.cmake
include/linux/compiler.h

index caf95951a7fe9ba420711c832dbf561c469d5494..81b1346ec9fc0005e0f095737b10e7c9328f94a1 100644 (file)
@@ -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)
 
index 5bde67505e2b0250003382d24dfb2a8afdc2179b..8f0b33e6b8b6065bef73a5a5c33d6cc1c6dcd860 100644 (file)
@@ -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) |
index 17cbaf922d06500a76234b4e78988edfc19cc76f..80e7e21ee45cee6d807fd7813333db4b35d92df3 100644 (file)
@@ -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);
 
index 7bbec4c15cdba88703c9e5ca313a0a88275820ce..191bf2eb29dd0b3045fd2ad2b327c234247c6b74 100644 (file)
@@ -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
index 8be6d3602279c8b284377dd6adcc2c6b2d6bfdfe..24294362c6cf3a329609ff091e268bdb93dfd0ae 100644 (file)
@@ -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 <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -o <TARGET>")
+set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_SOURCE_DIR}/toolchain/inst/bin/sh-elf-gcc <OBJECTS> ${CMAKE_C_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -o <TARGET>")
 
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
index d331f3c1fe043e15889f579f6830b47f99e4fbf0..b81bf1472800404745d444e0412f2e8304884a5f 100644 (file)
@@ -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)