Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

gcc, binutils: link to Cellar instead of system libs #200

Closed
wants to merge 1 commit into from

Conversation

jbaum98
Copy link
Contributor

@jbaum98 jbaum98 commented Dec 7, 2014

Symlinks linuxbrew/lib to Cellar for gcc, where gcc will automatically look because that is the prefix. Should fix the issue discussed recently in #107.

@sjackman sjackman self-assigned this Dec 7, 2014
@sjackman
Copy link
Member

sjackman commented Dec 7, 2014

Does this patch resolve your issue with GCC not finding crti.o? Can you report the output of gcc -v hello.c -o hello?

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 7, 2014

This fixed the issue with the xgcc being unable to find crti.o and libc_nonshare.a during installation, as well as the issue with gcc being unable to find crti.o after installation. I'm not sure which hello.c you're referring to, but I do know that brew install hello etc all works. With this patch Linuxbrew is actually working great on the Chromebook.

@sjackman
Copy link
Member

sjackman commented Dec 8, 2014

That's great! Can you report the result of brew test gcc?

hello.c is any old source file. For example

int main() { return 0; }

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 8, 2014

Results of brew test gcc

Testing gcc
==> /usr/local/linuxbrew/Cellar/gcc/4.9.2/bin/gcc-4.9 -o hello-c hello-c.c
==> /usr/local/linuxbrew/Cellar/gcc/4.9.2/bin/g++-4.9 -o hello-cc hello-cc.cc
==> /usr/local/linuxbrew/Cellar/gcc/4.9.2/bin/gfortran -c in.f90
==> /usr/local/linuxbrew/Cellar/gcc/4.9.2/bin/gfortran -o test in.o

Results of gcc -v hello.c -o hello

Reading specs from /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-native-system-header-dir=/usr/local/linuxbrew/include --with-build-time-tools=/usr/local/linuxbrew/Cellar/binutils/2.24/x86_64-unknown-linux-gnu/bin --with-boot-ldflags='-static-libstdc++ -static-libgcc -L/usr/local/linuxbrew/lib -Wl,--dynamic-linker=/usr/local/linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -Wl,-rpath,/usr/local/linuxbrew/lib' --prefix=/usr/local/linuxbrew/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/linuxbrew/opt/gmp --with-mpfr=/usr/local/linuxbrew/opt/mpfr --with-mpc=/usr/local/linuxbrew/opt/libmpc --with-cloog=/usr/local/linuxbrew/opt/cloog --with-isl=/usr/local/linuxbrew/opt/isl --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2 --with-glibc' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2 --with-glibc) 
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic' '-march=x86-64'
 /usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -march=x86-64 -auxbase hello -version -o /usr/local/tmp/ccHNKIqH.s
GNU C (Homebrew gcc 4.9.2 --with-glibc) version 4.9.2 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory "/usr/local/linuxbrew/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include
 /usr/local/include
 /usr/local/linuxbrew/Cellar/gcc/4.9.2/include
 /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include-fixed
End of search list.
GNU C (Homebrew gcc 4.9.2 --with-glibc) version 4.9.2 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 298d3c6a8cfe9994c02db8ddb6df3ac0
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic' '-march=x86-64'
 as -v --64 -o /usr/local/tmp/ccThhMC2.o /usr/local/tmp/ccHNKIqH.s
GNU assembler version 2.24 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=/usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mtune=generic' '-march=x86-64'
 /usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/collect2 -plugin /usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/liblto_plugin.so -plugin-opt=/usr/local/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper -plugin-opt=-fresolution=/usr/local/tmp/ccNc5bQn.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath /usr/local/linuxbrew/lib --dynamic-linker /usr/local/linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -o hello /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crt1.o /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crti.o /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtbegin.o -nostdlib -L/usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2 -L/usr/local/linuxbrew/lib /usr/local/tmp/ccThhMC2.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtend.o /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtn.o

@sjackman sjackman changed the title symlink lib to gcc Cellar so it links correctly gcc, glibc: symlink lib to gcc Cellar so it links correctly Dec 8, 2014
@sjackman
Copy link
Member

sjackman commented Dec 8, 2014

@jrevillard Does this patch fix your gfortran issue in #135?

@sjackman
Copy link
Member

sjackman commented Dec 8, 2014

In your gcc -v it finds the correct crti.o, which is good indeed. /usr/local/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crti.o

@sjackman
Copy link
Member

sjackman commented Dec 8, 2014

Mine does not

$ gcc hello-c.c -o hello-c -v
Reading specs from /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-native-system-header-dir=/gsc/btl/linuxbrew/include --with-build-time-tools=/gsc/btl/linuxbrew/Cellar/binutils/2.24/x86_64-unknown-linux-gnu/bin LDFLAGS='-L/gsc/btl/linuxbrew/lib -Wl,--dynamic-linker=/gsc/btl/linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -Wl,-rpath,/gsc/btl/linuxbrew/lib -Wl,-rpath,/usr/lib64 -Wl,-rpath,/lib64' --with-boot-ldflags='-static-libstdc++ -static-libgcc -L/gsc/btl/linuxbrew/lib -Wl,--dynamic-linker=/gsc/btl/linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -Wl,-rpath,/gsc/btl/linuxbrew/lib' --prefix=/gsc/btl/linuxbrew/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/gsc/btl/linuxbrew/opt/gmp --with-mpfr=/gsc/btl/linuxbrew/opt/mpfr --with-mpc=/gsc/btl/linuxbrew/opt/libmpc --with-cloog=/gsc/btl/linuxbrew/opt/cloog --with-isl=/gsc/btl/linuxbrew/opt/isl --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2 --with-glibc' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2 --with-glibc) 
COLLECT_GCC_OPTIONS='-o' 'hello-c' '-v' '-mtune=generic' '-march=x86-64'
 /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/cc1 -quiet -v hello-c.c -quiet -dumpbase hello-c.c -mtune=generic -march=x86-64 -auxbase hello-c -version -o /tmp/ccwThmSj.s
GNU C (Homebrew gcc 4.9.2 --with-glibc) version 4.9.2 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include
 /usr/local/include
 /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/include
 /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include-fixed
 /gsc/btl/linuxbrew/include
End of search list.
GNU C (Homebrew gcc 4.9.2 --with-glibc) version 4.9.2 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e604c918b089407dd95e2c8201583d61
COLLECT_GCC_OPTIONS='-o' 'hello-c' '-v' '-mtune=generic' '-march=x86-64'
 as -v --64 -o /tmp/ccT4bwE2.o /tmp/ccwThmSj.s
GNU assembler version 2.24 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'hello-c' '-v' '-mtune=generic' '-march=x86-64'
 /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/collect2 -plugin /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/liblto_plugin.so -plugin-opt=/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper -plugin-opt=-fresolution=/tmp/ccyNG2rL.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath /gsc/btl/linuxbrew/lib --dynamic-linker /gsc/btl/linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -o hello-c /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtbegin.o -nostdlib -L/gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2 -L/gsc/btl/linuxbrew/lib /tmp/ccT4bwE2.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /gsc/btl/linuxbrew/Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtend.o /usr/lib/../lib64/crtn.o

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 9, 2014

I made another change that I thought was unrelated but maybe you can try it and see if it changes anything. I added a configure flag --with-lib-path=/usr/local/linuxbrew/lib to binutils

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 9, 2014

I wasn't experiencing a gfortran issue but I think it's all working fine.

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 9, 2014

Also, I wrote this after linking this by hand, so I haven't had the chance to actually reinstall gcc with this (I've been enjoying my gcc too much). If it installs correctly, that means its doing the first linking correctly, but the second linking should result in crt1.o, crti.o, and crtn.o being linked from Cellar/gcc/vers/lib to Cellar/gcc/4.9.2/lib/gcc/x86_64-unknown-linux-gnu/4.9.2. If that isn't the case for you then the code not binutils is at fault.

@sjackman
Copy link
Member

sjackman commented Dec 9, 2014

I won't have time to look into this issue real soon. It would be great if you have time to test these ideas yourself, and if not, I'll get to it, but it may be a little while. This Christmas is busy busy.

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 9, 2014

No problem I'll get on it.

@jrevillard
Copy link

Hi,

Good to see that it's progressing :-). Unfortunatly, for me gcc does not compile anymore (I think that this is like this since the usage of the bottles.

/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _clrsbsi2.o -MT _clrsbsi2.o -MD -MP -MF _clrsbsi2.dep -DL_clrsbsi2 -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
../../../libgcc/libgcc2.c: In function '__mulxc3':
../../../libgcc/libgcc2.c:1966:21: internal compiler error: Illegal instruction
    if (isnan (c)) c = COPYSIGN (0, c);
                     ^
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _clrsbdi2.o -MT _clrsbdi2.o -MD -MP -MF _clrsbdi2.dep -DL_clrsbdi2 -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixunssfsi.o -MT _fixunssfsi.o -MD -MP -MF _fixunssfsi.dep -DL_fixunssfsi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixunsdfsi.o -MT _fixunsdfsi.o -MD -MP -MF _fixunsdfsi.dep -DL_fixunsdfsi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixunsxfsi.o -MT _fixunsxfsi.o -MD -MP -MF _fixunsxfsi.dep -DL_fixunsxfsi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
../../../libgcc/libgcc2.c: In function '__divxc3':
../../../libgcc/libgcc2.c:1921:26: internal compiler error: Illegal instruction
 #define COPYSIGN CONCAT2(__builtin_copysign, CEXT)
                          ^
../../../libgcc/libgcc2.c:1905:23: note: in definition of macro '_CONCAT2'
 #define _CONCAT2(A,B) A##B
                       ^
../../../libgcc/libgcc2.c:1921:18: note: in expansion of macro 'CONCAT2'
 #define COPYSIGN CONCAT2(__builtin_copysign, CEXT)
                  ^
../../../libgcc/libgcc2.c:2038:8: note: in expansion of macro 'COPYSIGN'
    x = COPYSIGN (INFINITY, c) * a;
        ^
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixsfdi.o -MT _fixsfdi.o -MD -MP -MF _fixsfdi.dep -DL_fixsfdi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixdfdi.o -MT _fixdfdi.o -MD -MP -MF _fixdfdi.dep -DL_fixdfdi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixxfdi.o -MT _fixxfdi.o -MD -MP -MF _fixxfdi.dep -DL_fixxfdi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/xgcc -B/tmp/gcc-X31264/gcc-4.9.2/build/./gcc/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/bin/ -B/home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/include -isystem /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/x86_64-unknown-linux-gnu/sys-include    -g -O2 -Os -w -pipe -march=core2 -O2  -g -O2 -Os -w -pipe -march=core2 -DIN_GCC    -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS -o _fixunssfdi.o -MT _fixunssfdi.o -MD -MP -MF _fixunssfdi.dep -DL_fixunssfdi -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
0xb61d44 crash_signal
    ../../gcc/toplev.c:337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://github.com/Homebrew/homebrew/issues> for instructions.
make[3]: *** [_mulxc3.o] Erreur 1
make[3]: *** Attente des tâches non terminées....
In file included from ../../../libgcc/libgcc2.c:56:0:
../../../libgcc/libgcc2.c: In function '__fixunsxfdi':
../../../libgcc/libgcc2.h:199:19: internal compiler error: Illegal instruction
 #define __NW(a,b) __ ## a ## di ## b
                   ^
../../../libgcc/libgcc2.h:298:22: note: in expansion of macro '__NW'
 #define __fixunsxfSI __NW(fixunsxf,)
                      ^
../../../libgcc/libgcc2.c:1788:1: note: in expansion of macro '__fixunsxfSI'
 __fixunsxfSI (XFtype a)
 ^
0xb61d44 crash_signal
    ../../gcc/toplev.c:337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://github.com/Homebrew/homebrew/issues> for instructions.
make[3]: *** [_divxc3.o] Erreur 1
0xb61d44 crash_signal
    ../../gcc/toplev.c:337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://github.com/Homebrew/homebrew/issues> for instructions.
make[3]: *** [_fixunsxfsi.o] Erreur 1
make[3]: quittant le répertoire « /tmp/gcc-X31264/gcc-4.9.2/build/x86_64-unknown-linux-gnu/libgcc »
make[2]: *** [all-stage1-target-libgcc] Erreur 2
make[2]: quittant le répertoire « /tmp/gcc-X31264/gcc-4.9.2/build »
make[1]: *** [stage1-bubble] Erreur 2
make[1]: quittant le répertoire « /tmp/gcc-X31264/gcc-4.9.2/build »
make: *** [bootstrap] Erreur 2
==> Configuration
HOMEBREW_VERSION: 0.9.5
HEAD: 1274ba7f92d932e0daa7971ea5aa666be36cca4d
HOMEBREW_PREFIX: /home/jerome/.linuxbrew
CPU: 8-core 64-bit 6
OS X: 0-x86_64
X11: N/A
==> ENV
CC: /home/jerome/.linuxbrew/bin/gcc-4.4 => /usr/bin/gcc44
CXX: /home/jerome/.linuxbrew/bin/g++-4.4 => /usr/bin/g++44
OBJC: /home/jerome/.linuxbrew/bin/gcc-4.4
OBJCXX: /home/jerome/.linuxbrew/bin/g++-4.4
HOMEBREW_CC: gcc-4.4
CFLAGS: -Os -w -pipe -march=core2
CXXFLAGS: -Os -w -pipe -march=core2
CPPFLAGS: -isystem/home/jerome/.linuxbrew/include
LDFLAGS: -L/home/jerome/.linuxbrew/lib -Wl,--dynamic-linker=/home/jerome/.linuxbrew/opt/glibc/lib/ld-linux-x86-64.so.2 -Wl,-rpath,/home/jerome/.linuxbrew/lib
MAKEFLAGS: -j8
CMAKE_PREFIX_PATH: /home/jerome/.linuxbrew
PKG_CONFIG_LIBDIR: /home/jerome/.linuxbrew/lib/pkgconfig:/usr/lib/pkgconfig
PATH: /home/jerome/.linuxbrew/bin:/home/jerome/.linuxbrew/sbin:/home/jerome/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin:/home/jerome/.linuxbrew/Library/ENV/scm

Error: gcc 4.9.2 did not build
Logs:
     /home/jerome/Library/Logs/Homebrew/gcc/02.make
     /home/jerome/Library/Logs/Homebrew/gcc/01.configure

These open issues may also help:
gcc 4.9.2 fails to produce debugging information (https://github.com/Homebrew/homebrew/issues/34976)
--cc=gcc-4.9 gets me in an infinite loop (https://github.com/Homebrew/homebrew/issues/33731)
MacOS.(gcc|clang|llvm)_version can return nil (https://github.com/Homebrew/homebrew/issues/18781)

For information, I'm compiling on SL5 using the gcc44 compiler. I will try without the bottles to see if it works better.

Best,
Jerome

@jrevillard
Copy link

@jbaum98 , @sjackman ... what can I say ... YOUHHHHHHHHOUUUUUUU ! :-)

It works, my gfortran works with the standalone installation using the very last version of your gcc formula!

[jerome@srv11:~] 23s $ brew test gcc
Testing gcc
==> /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/bin/gcc-4.9 -o hello-c hello-c.c
==> /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/bin/g++-4.9 -o hello-cc hello-cc.cc
==> /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/bin/gfortran -c in.f90
==> /home/jerome/.linuxbrew/Cellar/gcc/4.9.2/bin/gfortran -o test in.o

Thanks a million for your work guys!

Best,
Jerome

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 16, 2014

I'm glad its working for you @jrevillard! Just curious, did you reinstall binutils first, because I made a change in that formula too that was vital on my computer.

@jrevillard
Copy link

No simply because I did not notice it before merging your patch to my repo :-)

@jbaum98
Copy link
Contributor Author

jbaum98 commented Dec 16, 2014

No problem I was just curious whether or not it was necessary on other computers, and I guess it is not.

@sjackman
Copy link
Member

Excellent news! Thanks for your solution @jbaum98 and for your help troubleshooting @jrevillard. I probably won't find time to merge this until the new year, but I look forward to getting this fixed once and for all. A working Fortran compiler will be a big improvement for scientific computing using a standalone installation of Linuxbrew.

@jbaum98 jbaum98 changed the title gcc, glibc: symlink lib to gcc Cellar so it links correctly gcc, binutils: link to Cellar instead of system libs Dec 19, 2014
@simonlegrand
Copy link

Thanks a lot to all of you! I had the same troubles with crti.o on an ubuntu 12.04 where I´m not root. This patch works perfectly!

if OS.linux?
@link = Pathname.new "#{prefix}/x86_64-unknown-linux-gnu/bin"
@link.parent.mkpath
@link.make_symlink "#{HOMEBREW_PREFIX}/lib"
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this chunk? Does GCC search "#{prefix}/x86_64-unknown-linux-gnu/bin" for libraries? Seems odd to search bin for libs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem a little strange, but what I figured out was that the libs need to be passed to xgcc in -B options, and this is one of the default locations. I couldn't figure out a way to control what was passed to xgcc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's also relate to the GCC_EXEC_PREFIX environment variable: https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html#Environment-Variables

@jrevillard
Copy link

@jbaum98 to better answer your question about your modification of binutils, in fact, glibc does not compile anymore with your modification, reverting your change make it compile without any issue.
(For information,I'm on a system where the default gcc compiler used to boostrap is not installed in the default place and I then face this issue with the binutils patch).
I cannot give you the full output as many other things are compiling actually but I will try to do it after.

Best,
Jerome

@davydden
Copy link
Contributor

so it seems that gfortran issue is still open on a stand-alone installation?..

thanks for you work, this PR helped a lot. I installed a standalone linuxbrew on OpenSuse and so far managed to install openmpi and openblas, both need fortran compiler.

@bobobo1618
Copy link
Contributor

So I managed to build GCC with this patch but attempting to build Homebrew packages using the new GCC results in the following error:

Error: undefined method `gcc-4.9_build_version' for OS::Mac:Module
Please report this bug:
    https://github.com/Homebrew/linuxbrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting
/media/drive/home/user/.linuxbrew/Library/Homebrew/compilers.rb:119:in `block in find_compiler'
/media/drive/home/user/.linuxbrew/Library/Homebrew/compilers.rb:106:in `each'
/media/drive/home/user/.linuxbrew/Library/Homebrew/compilers.rb:106:in `find_compiler'
/media/drive/home/user/.linuxbrew/Library/Homebrew/compilers.rb:99:in `compiler'
/media/drive/home/user/.linuxbrew/Library/Homebrew/compilers.rb:82:in `select_for'
/media/drive/home/user/.linuxbrew/Library/Homebrew/extend/ENV/shared.rb:123:in `compiler'
/media/drive/home/user/.linuxbrew/Library/Homebrew/extend/ENV/std.rb:74:in `setup_build_environment'
/media/drive/home/user/.linuxbrew/Library/Homebrew/build.rb:90:in `install'
/media/drive/home/user/.linuxbrew/Library/Homebrew/build.rb:179:in `<main>'

I simply edited compilers.rb, took out the switch statement and hard coded it to the :gnu case and it works. That seems terribly hacky though and I'm sure there's something up. Shouldn't :gnu be triggered anyway?

@iggyvolz
Copy link
Contributor

Looks like #404 where it ignores HOMEBREW_CC. Using --cc=gcc4.9 should fix the problem

@sjackman
Copy link
Member

This bug should be fixed upstream by Homebrew/legacy-homebrew@43c634f, which has been merged.

@ahundt
Copy link

ahundt commented Sep 12, 2015

Can issues discussed here be related to the problems I'm encountering in #530? I may also be encountering the crtn.o issues discussed here.

sjackman added a commit that referenced this pull request Jan 22, 2016
Set LIBRARY_PATH so that GCC knows where to find the glibc libraries
and object files, such as crt1.o, crti.o and crtn.o.

See #107
See #200
@sjackman
Copy link
Member

@jrevillard I believe that 9318c13 should fix the gfortran issue.
@jbaum98 Fixing the search path for crti.o and friends when linking other programs should be possible by adding -B#{HOMEBREW_PREFIX}/lib to LDFLAGS in ENV/std.rb.

I'm going to close this PR. Thanks for all your help in troubleshooting. If you still have current issues, please do comment or open a new issue to discuss them.

@sjackman sjackman closed this Jan 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants