Linuxbrew / legacy-linuxbrew

:skull: This repository is defunct, because it has been split into https://github.com/Linuxbrew/brew and https://github.com/Linuxbrew/homebrew-core
http://linuxbrew.sh
Other
2.23k stars 295 forks source link

ENV.cxx detecting system g++ not Brew g++ #1035

Closed tseemann closed 8 years ago

tseemann commented 8 years ago

I was just writing a new formula today for the SDSL-Lite library and am having strange issues with the test block where I compile a small .cpp file for library. It's C++11.

% which g++
/bio/linuxbrew/bin/g++

% g++ --version
g++ (Homebrew gcc 5.3.0) 5.3.0

> puts ENV.cc # in test block
/usr/bin/gcc

> puts ENV.cxx # in test block
/usr/bin/g++

> ENV.cxx11
The selected compiler doesn't support C++11: gcc
/bio/linuxbrew/Library/Homebrew/extend/ENV/std.rb:318:in `cxx11'

This is the code, which assumes that g++ has it's version suffixed on it?

  def cxx11
    if compiler == :clang
      append "CXX", "-std=c++11"
      append "CXX", "-stdlib=libc++"
    elsif compiler =~ /gcc-(4\.(8|9)|5)/
      append "CXX", "-std=c++11"
    else
      raise "The selected compiler doesn't support C++11: #{compiler}"
    end
  end

Recent commit involving this file: https://github.com/Linuxbrew/linuxbrew/commits/e2f0212222c747eb84d6585097c46f7f5ddfd7be/Library/Homebrew/extend/ENV/std.rb

commit e2f0212222c747eb84d6585097c46f7f5ddfd7be
Merge: 59fc90c 5991466
Author: Shaun Jackman <sjackman@gmail.com>
Date:   Wed Mar 23 11:30:52 2016 -0700

    Merge branch homebrew/master into linuxbrew/master

    Conflicts:
        Library/Homebrew/extend/ENV/std.rb

Maybe something to do with new HOMEBREW_ENV_PATH ? Or #1033 ?

sjackman commented 8 years ago

I have noticed myself that ENV.cc is always set to /usr/bin/gcc in the test do block. I'll look into it.

sjackman commented 8 years ago

Fixed. Can you confirm that the fix works for you, Torsten?

tseemann commented 8 years ago

:+1: : Yes this solves the problem - it now finds the correct gcc-5.

Although the test works on the command line but fails in the test block too, with an error i've not seen before:

brew test ./sdsl-lite.rb
Testing sdsl-lite
==> /bio/linuxbrew/bin/g++-5 -std=c++11 -o fm-index -I/bio/linuxbrew/opt/sdsl-lite/include /bio/linuxbrew/Cellar/sdsl-lite/2.0.3/share/sdsl-lite/examples/fm-index.cpp -L/bio/linu
Last 15 lines from /home/tseemann/.cache/Homebrew/Logs/sdsl-lite/01.g++-5:
2016-04-05 12:30:15 +1000

/bio/linuxbrew/bin/g++-5 -std=c++11
-o
fm-index
-I/bio/linuxbrew/opt/sdsl-lite/include
/bio/linuxbrew/Cellar/sdsl-lite/2.0.3/share/sdsl-lite/examples/fm-index.cpp
-L/bio/linuxbrew/opt/sdsl-lite/lib
-lsdsl
-ldivsufsort
-ldivsufsort64

Error: sdsl-lite: failed
Failed executing: /bio/linuxbrew/bin/g++-5 -std=c++11 -o fm-index -I/bio/linuxbrew/opt/sdsl-lite/include /bio/linuxbrew/Cellar/sdsl-lite/2.0.3/share/sdsl-lite/examples/fm-index.cpp -L/bio/linuxbrew/opt/sdsl-lite/lib -lsdsl -ldivsufsort -ldivsufsort64
/bio/linuxbrew/Library/Homebrew/formula.rb:1484:in `block in system'
/bio/linuxbrew/Library/Homebrew/formula.rb:1421:in `open'
/bio/linuxbrew/Library/Homebrew/formula.rb:1421:in `system'
/home/tseemann/git/homebrew-science/sdsl-lite.rb:28:in `block in <class:SdslLite>'
/bio/linuxbrew/Library/Homebrew/formula.rb:1330:in `block in run_test'
/bio/linuxbrew/Library/Homebrew/extend/fileutils.rb:37:in `mktemp'
/bio/linuxbrew/Library/Homebrew/formula.rb:1326:in `run_test'
/bio/linuxbrew/Library/Homebrew/test.rb:32:in `block in <main>'
/bio/linuxbrew/Cellar/ruby/2.3.0/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/bio/linuxbrew/Cellar/ruby/2.3.0/lib/ruby/2.3.0/timeout.rb:33:in `block in catch'
/bio/linuxbrew/Cellar/ruby/2.3.0/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/bio/linuxbrew/Cellar/ruby/2.3.0/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/bio/linuxbrew/Cellar/ruby/2.3.0/lib/ruby/2.3.0/timeout.rb:106:in `timeout'
/bio/linuxbrew/Library/Homebrew/test.rb:31:in `<main>'
sjackman commented 8 years ago

I thought sdsl-lite was packaged? Am I nuts? Where does it live?

$ brew search sdsl
No formula found for "sdsl".
==> Searching pull requests...
sjackman commented 8 years ago

My fix for this issue fixed brew test, but it doesn't fix brew sh, which starts with CC=/usr/bin/gcc. I'd like to fix that.