• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/fastd/0001-cmake-use-INTERPROCEDURAL_OPTIMIZATION-target-proper.patch
Alexander DahlAlexander Dahl committed c60243e0a9902 Apr 2016
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
From: Alexander Dahl <alex@netz39.de>
2
Date: Wed, 28 Oct 2015 16:04:13 +0100
3
Subject: [PATCH] cmake: use INTERPROCEDURAL_OPTIMIZATION target property
4
​
5
Instead of hacking on compiler flags use the cmake way for handling
6
interprocedural optimization. Tests showed cmake currently ignores this
7
for gcc and clang, at least on Debian Wheezy and Jessie. This actually
8
results in no interprocedural optimization for the moment. However it
9
allows to compile fastd against a toolchain without LTO support, which
10
was broken because of a hack included here for finding binutils.
11
​
12
According to the upstream author of fastd the main reason for enabling
13
LTO was binary size on an OpenWRT target for Freifunk Gluon, where they
14
have very few space left on devices with only 4 MB flash memory.
15
​
16
Signed-off-by: Alexander Dahl <post@lespocky.de>
17
---
18
 cmake/checks.cmake | 14 --------------
19
 src/CMakeLists.txt |  9 +++++++++
20
 2 files changed, 9 insertions(+), 14 deletions(-)
21
​
22
diff --git a/cmake/checks.cmake b/cmake/checks.cmake
23
index 27c073f..8a671a1 100644
24
--- a/cmake/checks.cmake
25
+++ b/cmake/checks.cmake
26
@@ -10,20 +10,6 @@ if(ARCH_X86 OR ARCH_X86_64)
27
 endif(ARCH_X86 OR ARCH_X86_64)
28
 
29
 
30
-
31
-if(ENABLE_LTO)
32
-  set(CFLAGS_LTO "-flto")
33
-  set(CFLAGS_NO_LTO "-fno-lto")
34
-
35
-  check_c_compiler_flag("-fwhole-program" HAVE_FLAG_WHOLE_PROGRAM)
36
-  if(HAVE_FLAG_WHOLE_PROGRAM)
37
-    set(LDFLAGS_LTO "-flto -fwhole-program")
38
-  else(HAVE_FLAG_WHOLE_PROGRAM)
39
-    set(LDFLAGS_LTO "-flto")
40
-  endif(HAVE_FLAG_WHOLE_PROGRAM)
41
-endif(ENABLE_LTO)
42
-
43
-
44
 check_c_source_compiles("
45
 #include <sys/types.h>
46
 #include <sys/socket.h>
47
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
48
index 829b3ab..7612b40 100644
49
--- a/src/CMakeLists.txt
50
+++ b/src/CMakeLists.txt
51
@@ -48,6 +48,15 @@ add_executable(fastd
52
 set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
53
 set_property(TARGET fastd PROPERTY LINK_FLAGS "${PTHREAD_LDFLAGS} ${LIBUECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER} ${JSON_C_LDFLAGS_OTHER} ${LDFLAGS_LTO}")
54
 set_property(TARGET fastd APPEND PROPERTY INCLUDE_DIRECTORIES ${LIBCAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIR})
55
+if(ENABLE_LTO)
56
+   set_target_properties(fastd PROPERTIES
57
+       INTERPROCEDURAL_OPTIMIZATION ON
58
+   )
59
+else(ENABLE_LTO)
60
+   set_target_properties(fastd PROPERTIES
61
+       INTERPROCEDURAL_OPTIMIZATION OFF
62
+   )
63
+endif(ENABLE_LTO)
64
 target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${LIBCAP_LIBRARY} ${LIBUECC_LIBRARIES} ${NACL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${JSON_C_LIBRARIES})
65
 
66
 add_dependencies(fastd version)
67
-- 
68
2.1.4
69
​
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.