Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions script/build-seccomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@ function build_libseccomp() {
make install
make clean

# Save the original cflags.
local original_cflags="${CFLAGS:-}"

# Build and install for all requested architectures.
local arch
for arch in "${arches[@]}"; do
# Reset CFLAGS.
CFLAGS="$original_cflags"
set_cross_vars "$arch"
./configure --host "$HOST" \
--prefix="$dest/$arch" --libdir="$dest/$arch/lib" \
Expand Down
9 changes: 6 additions & 3 deletions script/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function get_platform() {
# based on the architecture specified in $1.
function set_cross_vars() {
GOARCH="$1" # default, may be overridden below
local cc_flags=""
unset GOARM

PLATFORM="$(get_platform)"
Expand All @@ -47,7 +48,9 @@ function set_cross_vars() {
cpu_type=i686
fi
HOST=x86_64-${PLATFORM}
CFLAGS="-m32 -march=$cpu_type ${CFLAGS[*]}"
# Pass these via CC rather than CFLAGS, so that autoconf
# still uses its default CFLAGS (-g -O2) when CFLAGS is unset.
cc_flags=" -m32 -march=$cpu_type"
;;
amd64)
HOST=x86_64-${PLATFORM}
Expand Down Expand Up @@ -80,8 +83,8 @@ function set_cross_vars() {
;;
esac

CC="${HOST:+$HOST-}gcc"
CC="${HOST:+$HOST-}gcc${cc_flags}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little worried that "$CC" foo will now break in non-obvious ways and only when building x86 binaries. :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, info autoconf says (in CFLAGS description):

If it affects only the compiler proper, ‘CFLAGS’ is the natural home for it. If an option affects multiple phases of the compiler, though, matters get tricky:

• If an option selects a 32-bit or 64-bit build on a bi-arch system, it must be put direcly into ‘CC’, e.g., ‘CC='gcc -m64'’. This is necessary for ‘config.guess’ to work right.
• Otherwise one approach is to put the option into ‘CC’. Another is to put it into both ‘CPPFLAGS’ and ‘LDFLAGS’, but not into ‘CFLAGS’.

this is exactly what we do here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah if you mean if we'll quote $CC and it will fail in a non-obvious way -- I think it will fail in a very obvious way, saying something like:

bash: gcc -m32 -march=i686: command not found...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if autoconf says to do that then who am I to argue?

STRIP="${HOST:+$HOST-}strip"

export HOST CFLAGS GOARM GOARCH CC STRIP
export HOST GOARM GOARCH CC STRIP
}
5 changes: 0 additions & 5 deletions script/release_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,9 @@ function build_project() {
# it can reuse cached pkg-config results).
local make_args=(COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static)

# Save the original cflags.
local original_cflags="${CFLAGS:-}"

# Build for all requested architectures.
local arch
for arch in "${arches[@]}"; do
# Reset CFLAGS.
CFLAGS="$original_cflags"
set_cross_vars "$arch"
make -C "$root" \
PKG_CONFIG_PATH="$dylibdir/$arch/lib/pkgconfig" \
Expand Down