From 2bedc5c9dfbce63f3495357bc9e75fa906b75205 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Fri, 9 Jun 2017 08:05:21 -0500 Subject: [PATCH] Link to libstdc++ statically. (#4016) * Link to libstdc++ statically. * use a linker flag instead. * Update Build.PL * Link to static paths on Travis only. * Fix SFTP to abort of SFTP errors. * Create sftp.sh * always set -static-libstdc++ now in ldflags also removed gcc 4.6 workaround * remove buggy gcc check for 4.7, it is no longer supported * Remove -lstdc++ Static linking is done on Travis for linux. * Filter -lstdc++ on linux, static c++ --- .travis.yml | 1 - package/deploy/sftp.sh | 10 +++++++++- xs/Build.PL | 41 ++++++++++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index f399c1de8..1bfbb3ba7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: perl before_install: - sh package/linux/travis-decrypt-key install: -- export LDLOADLIBS=-lstdc++ - export BOOST_DIR=$HOME/boost_1_63_0 - export SLIC3R_STATIC=1 - export CXX=g++-4.9 diff --git a/package/deploy/sftp.sh b/package/deploy/sftp.sh index 3fc786fc3..14ffa6aab 100755 --- a/package/deploy/sftp.sh +++ b/package/deploy/sftp.sh @@ -19,8 +19,16 @@ fi if [ -s $KEY ]; then for i in $FILES; do filepath=$(readlink -f "$i") - echo put $filepath | sftp -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/" + tmpfile=$(mktemp) + echo put $filepath > $tmpfile + sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/" + result=$? + if [ $? -eq 1 ]; then + echo "Error with SFTP" + exit $result; + fi done else echo "$KEY is not available, not deploying." fi +exit $result diff --git a/xs/Build.PL b/xs/Build.PL index 2633b8870..b59e2fb57 100644 --- a/xs/Build.PL +++ b/xs/Build.PL @@ -10,6 +10,7 @@ use Module::Build::WithXSpp; my $cpp_guess = ExtUtils::CppGuess->new; my $mswin = $^O eq 'MSWin32'; +my $linux = $^O eq 'linux'; # prevent an annoying concatenation warning by Devel::CheckLib $ENV{LD_RUN_PATH} //= ""; @@ -23,14 +24,32 @@ if ($cpp_guess->is_gcc) { # GCC is pedantic with c++11 std, so undefine strict ansi to get M_PI back push @cflags, qw(-U__STRICT_ANSI__); } -if (`$Config{cc} -v` =~ /gcc version 4\.6\./) { - # Compatibility with GCC 4.6 is not a requirement, but as long as code compiles on it we try to support it. - push @cflags, qw(-std=c++0x); -} else { - # std=c++11 Enforce usage of C++11 (required now). Minimum compiler supported: gcc 4.9, clang 3.3, MSVC 14.0 - push @cflags, qw(-std=c++11); -} + +# std=c++11 Enforce usage of C++11 (required now). Minimum compiler supported: gcc 4.9, clang 3.3, MSVC 14.0 +push @cflags, qw(-std=c++11); + my @ldflags = (); + +if ($linux && (defined $ENV{SLIC3R_STATIC} && $ENV{SLIC3R_STATIC})) { + push @ldflags, qw(-static-libgcc -static-libstdc++); + if ($ENV{TRAVIS}) { + # On the build server, link to the actual static libraries to make sure we get them in the list. + push @ldflags, qw(/usr/lib/gcc/x86_64-linux-gnu/4.9/libstdc++.a /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a); + } + # ExtUtils::CppGuess has a hard-coded -lstdc++, so we filter it out + { + no strict 'refs'; + no warnings 'redefine'; + my $func = "ExtUtils::CppGuess::_get_lflags"; + my $orig = *$func{CODE}; + *{$func} = sub { + my $lflags = $orig->(@_); + $lflags =~ s/\s*-lstdc\+\+//; + return $lflags; + }; + } +} + if ($^O eq 'darwin') { push @cflags, qw(-stdlib=libc++); push @ldflags, qw(-framework IOKit -framework CoreFoundation -lc++); @@ -195,14 +214,6 @@ if ($ENV{SLIC3R_DEBUG}) { push @cflags, '-DNDEBUG'; } if ($cpp_guess->is_gcc) { - # check whether we're dealing with a buggy GCC version - # see https://github.com/alexrj/Slic3r/issues/1965 - if (`cc --version` =~ / 4\.7\.[012]/) { - # Workaround suggested by Boost devs: - # https://svn.boost.org/trac/boost/ticket/8695 - push @cflags, qw(-fno-inline-small-functions); - } - # our templated XS bindings cause undefined-var-template warnings push @cflags, qw(-Wno-undefined-var-template); }