Skip to content

Commit

Permalink
Set CFLAGS/LDFLAGS/etc according to Debian policy
Browse files Browse the repository at this point in the history
Debian wants to build all binaries with particular hardening flags.
The Rust makefiles are inconsistent in which architectures they
correctly include CFLAGS/etc from the enivoronment (see mk/cfg/*).

This patch adds LDFLAGS, and then unconditionally prepends
CFLAGS/LDFLAGS/etc to the build commands.
  • Loading branch information
Angus Lees authored and bltavares committed Nov 20, 2015
1 parent 6861c51 commit 07b7f2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions configure
Expand Up @@ -1053,12 +1053,13 @@ fi
# point in the script; after this point, script logic should inspect
# $CFG_USING_CLANG rather than $CFG_ENABLE_CLANG.

# Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS}
# Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS,LDFLAGS}
envopt CC
envopt CXX
envopt CPP
envopt CFLAGS
envopt CXXFLAGS
envopt LDFLAGS

# stdc++ name in use
# used to manage non-standard name (on OpenBSD for example)
Expand Down Expand Up @@ -1667,9 +1668,9 @@ do

CXX=$LLVM_CXX
CC=$LLVM_CC
CFLAGS=$LLVM_CFLAGS
CXXFLAGS=$LLVM_CXXFLAGS
LDFLAGS=$LLVM_LDFLAGS
CFLAGS="$CFLAGS $LLVM_CFLAGS"
CXXFLAGS="$CXXFLAGS $LLVM_CXXFLAGS"
LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"

if [ -z "$CFG_DISABLE_LIBCPP" ] && [ -n "$CFG_USING_CLANG" ]; then
LLVM_OPTS="$LLVM_OPTS --enable-libcpp"
Expand Down
4 changes: 4 additions & 0 deletions mk/platform.mk
Expand Up @@ -189,21 +189,25 @@ define CFG_MAKE_TOOLCHAIN
endif

CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
$$(CFLAGS) \
$$(CFG_GCCISH_CFLAGS) \
$$(CFG_GCCISH_CFLAGS_$(1)) \
-c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
CFG_LINK_C_$(1) = $$(CC_$(1)) \
$$(LDFLAGS) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
$$(call CFG_INSTALL_NAME_$(1),$$(4))
CFG_COMPILE_CXX_$(1) = $$(CXX_$(1)) \
$$(CXXFLAGS) \
$$(CFG_GCCISH_CFLAGS) \
$$(CFG_GCCISH_CXXFLAGS) \
$$(CFG_GCCISH_CFLAGS_$(1)) \
$$(CFG_GCCISH_CXXFLAGS_$(1)) \
-c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
CFG_LINK_CXX_$(1) = $$(CXX_$(1)) \
$$(LDFLAGS) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
Expand Down

0 comments on commit 07b7f2f

Please sign in to comment.