Skip to content

Commit

Permalink
Don't hardcode references to libstcd++
Browse files Browse the repository at this point in the history
In the past we wrongly used the C linker so we ended up with these
libraries explicitly linked. We now properly link C++ code with CXX.
This means we don't need to explicitly link the C++ standard library.

This also fixes issues with FreeBSD which has switch to clang / libc++
as the default instead of libstdc++.

Also see #2900
  • Loading branch information
dbussink committed Jan 23, 2014
1 parent bf35706 commit 716e662
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ Unsupported language version requested: #{version}. Options are #{@supported_ver
end

def setup_platform
@ldsharedxx = "#{@cxx} -shared -lstdc++"
@ldsharedxx = "#{@cxx} -shared"
@ldshared = "#{@cc} -shared"

@include_dirs.each do |d|
Expand Down Expand Up @@ -996,7 +996,7 @@ Unsupported language version requested: #{version}. Options are #{@supported_ver
@features["rpath"].configured = false
@make = "gmake"
when /freebsd/i
@ldsharedxx = "#{@cxx} -shared -lstdc++ -fPIC"
@ldsharedxx = "#{@cxx} -shared -fPIC"
@ldshared = "#{@cc} -shared -fPIC"
@system_cflags << "-fPIC"
@system_ldflags << "-lcrypt -pthread -rdynamic"
Expand All @@ -1020,7 +1020,7 @@ Unsupported language version requested: #{version}. Options are #{@supported_ver
when /darwin/i
# on Unix we need a g++ link, not gcc.
# Ff line contributed by Daniel Harple.
@ldsharedxx = "#{@cxx} -bundle -undefined suppress -flat_namespace -lstdc++"
@ldsharedxx = "#{@cxx} -bundle -undefined suppress -flat_namespace"
@ldshared = "#{@cc} -bundle -undefined suppress -flat_namespace"
@system_cflags << "-fPIC -D_DARWIN_USE_64_BIT_INODE"
@features["rpath"].configured = false
Expand Down Expand Up @@ -1062,7 +1062,7 @@ Unsupported language version requested: #{version}. Options are #{@supported_ver

libs = (default_link_libs + link_libs).map { |l| "-l#{l}" }.join(" ")

cmd = "#{@cxx} #{@user_cppflags} #{@user_cflags} #{@user_cxxflags} #{@user_ldflags} -o #{basename} #{source} #{@system_cppflags} #{@system_cflags} #{@system_cxxflags} #{@system_ldflags} -lstdc++ #{libs} >>#{@log.path} 2>&1"
cmd = "#{@cxx} #{@user_cppflags} #{@user_cflags} #{@user_cxxflags} #{@user_ldflags} -o #{basename} #{source} #{@system_cppflags} #{@system_cflags} #{@system_cxxflags} #{@system_ldflags} #{libs} >>#{@log.path} 2>&1"
@log.log cmd
system cmd
return $?.exitstatus unless run
Expand Down
2 changes: 1 addition & 1 deletion rakelib/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
gcc.cflags << "-D#{flag}"
end

gcc.ldflags << "-lstdc++" << "-lm"
gcc.ldflags << "-lm"

make = Rubinius::BUILD_CONFIG[:build_make]

Expand Down

0 comments on commit 716e662

Please sign in to comment.