-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add CONFIG_LTO to enable link-time optimization
Change-Id: I9546d715b8d2ca3ebf46183bdbaa58e8aa921d95 Signed-off-by: Daniel Verkamp <[email protected]> Signed-off-by: Ben Walker <[email protected]>
- Loading branch information
1 parent
6a8cd33
commit 6d6d116
Showing
6 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ CONFIG.local | |
.project | ||
.cproject | ||
.settings | ||
mk/cc.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
function err() | ||
{ | ||
echo "$@" >&2 | ||
} | ||
|
||
function usage() | ||
{ | ||
err "Detect compiler and linker versions, generate mk/cc.mk" | ||
err "" | ||
err "Usage: ./detect_cc.sh [OPTION]..." | ||
err "" | ||
err "Defaults for the options are specified in brackets." | ||
err "" | ||
err "General:" | ||
err " -h, --help Display this help and exit" | ||
err " --cc=path C compiler to use" | ||
err " --cxx=path C++ compiler to use" | ||
err " --lto=[y|n] Attempt to configure for LTO" | ||
|
||
} | ||
|
||
CC=cc | ||
CXX=c++ | ||
LTO=n | ||
|
||
for i in "$@"; do | ||
case "$i" in | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
--cc=*) | ||
CC="${i#*=}" | ||
;; | ||
--cxx=*) | ||
CXX="${i#*=}" | ||
;; | ||
--lto=*) | ||
LTO="${i#*=}" | ||
;; | ||
--) | ||
break | ||
;; | ||
*) | ||
err "Unrecognized option $i" | ||
usage | ||
exit 1 | ||
esac | ||
done | ||
|
||
CC_TYPE=$($CC -v 2>&1 | grep version | awk '{print $1}') | ||
CXX_TYPE=$($CXX -v 2>&1 | grep version | awk '{print $1}') | ||
LD_TYPE=$(ld -v 2>&1 | awk '{print $2}') | ||
|
||
if [ "$CC_TYPE" != "$CXX_TYPE" ]; then | ||
err "C compiler is $CC_TYPE but C++ compiler is $CXX_TYPE" | ||
err "This may result in errors" | ||
exit 1 | ||
fi | ||
|
||
CCAR="ar" | ||
if [ "$LTO" = "y" ]; then | ||
if [ "$CC_TYPE" = "clang" ]; then | ||
if [ "$LD_TYPE" != "gold" ]; then | ||
err "Using LTO with clang requires the gold linker." | ||
exit 1 | ||
fi | ||
CCAR="llvm-ar" | ||
else | ||
CCAR="gcc-ar" | ||
fi | ||
fi | ||
|
||
echo "CC=$CC" | ||
echo "CXX=$CXX" | ||
echo "CCAR=$CCAR" |