Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Nov 2016 18:39:37 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   [Bug 214404] base/gcc: and base/binutils -r424540 for TARGET_ARCH=powerpc64 example: file placement and gcc/g++ internal file lookups do not match so gcc/g++ do not work
Message-ID:  <bug-214404-13@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D214404

            Bug ID: 214404
           Summary: base/gcc: and base/binutils -r424540 for
                    TARGET_ARCH=3Dpowerpc64 example: file placement and
                    gcc/g++ internal file lookups do not match so gcc/g++
                    do not work
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: freebsd-ports-bugs@FreeBSD.org
          Reporter: markmi@dsl-only.net

[This is after dealing with mpfr 3.1.4 vs. 3.1.5, adding gcc and g++ comman=
ds
to my environment, and updating pkg.plist for TARGET_ARCH=3Dpowerpc64 . Thi=
s is
use on the powerpc64 context, not the cross build.]

The gcc (and cc) from base/gcc 's freebsd-gcc-5.4.0.txz for powerpc64 (via
cross builds) by default can not find ld from either the system ( /usr/bin/=
ld )
or from base/binutils 's FreeBSD-binutils-2.25.1_3,1.txz expanded content :

> # cc main.c
> collect2: fatal error: cannot find 'ld'
> compilation terminated.

Before showing truss output that reports for where ld is searched for: here=
 is
were it actually is (along with some other files that match the pattern tha=
t I
used):

> # find / -name "*ld" -print | grep "[/-]ld$"
> /usr/src/contrib/netbsd-tests/usr.bin/ld
> /usr/src/contrib/binutils/ld
> /usr/src/gnu/usr.bin/binutils/ld
> /usr/bin/ld
> /usr/ports/devel/bcc/files/patch-ld
> /usr/powerpc64-freebsd/bin/ld

(The "env ABI=3DFreeBSD:12:powerpc64 pkg-static add
FreeBSD-binutils-2.25.1_3,1.txz" generated that last line's file.)

The "truss -f output cc main.c" output shows none of those paths being
involved. It does show a stat for:

> /usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld

and another for:

> /bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld

among others. (ld is not the only thing with such a naming convention for w=
hat
is before the tool's base name.) None of the paths end in "/ld" : all end in
"-ld". None of the lookups are directly in /usr either: if /usr is involved=
 in
the path then so is at least one subdirectory.

The truss "ld" lookup reports are included in the output below, they are all
not-found failures:

> # truss -f cc main.c 2>&1 | grep '[/-]ld"'=20
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/real-ld=
",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/real-ld=
",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/real-ld",0xff=
ffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/real-ld",0x=
ffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/real-ld",0xffffff=
ffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/collect=
-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/collect=
-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/collect-ld",0=
xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/collect-ld"=
,0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/collect-ld",0xfff=
fffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc=
64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc=
64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/powerpc64-fre=
ebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc64-f=
reebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/powerpc64-freebsd=
-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/sbin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld",0x=
ffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld",0xf=
fffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/sbin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld=
",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld"=
,0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/local/sbin/powerpc64-portbld-freebsd12.0-powerpc64-free=
bsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/local/bin/powerpc64-portbld-freebsd12.0-powerpc64-freeb=
sd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/home/markmi/bin/powerpc64-portbld-freebsd12.0-powerpc64-fre=
ebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'

Other files' naming differences are not necessarily the same so I list some=
 for
reference.

First: all the "truss -f cc main.c" references to /usr/bin/ are:

> # truss -f cc main.c 2>&1 | grep /usr/bin/
>  3040: access("/usr/bin/cc",X_OK)		 =3D 0 (0x0)
>  3040: stat("/usr/bin/cc",{ mode=3D-r-xr-xr-x ,inode=3D21028101,size=3D26=
28488,blksize=3D32768 }) =3D 0 (0x0)
>  3040: lstat("/usr/bin/cc",{ mode=3Dlrwxr-xr-x ,inode=3D21028094,size=3D3=
3,blksize=3D32768 }) =3D 0 (0x0)
>  3040: readlink("/usr/bin/cc","powerpc64-portbld-freebsd12.0-gcc",1023) =
=3D 33 (0x21)
>  3040: lstat("/usr/bin/powerpc64-portbld-freebsd12.0-gcc",{ mode=3D-r-xr-=
xr-x ,inode=3D21028101,size=3D2628488,blksize=3D32768 }) =3D 0 (0x0)
>  3040: access("/usr/bin/cc",X_OK)		 =3D 0 (0x0)
>  3040: stat("/usr/bin/cc",{ mode=3D-r-xr-xr-x ,inode=3D21028101,size=3D26=
28488,blksize=3D32768 }) =3D 0 (0x0)
>  3040: lstat("/usr/bin/cc",{ mode=3Dlrwxr-xr-x ,inode=3D21028094,size=3D3=
3,blksize=3D32768 }) =3D 0 (0x0)
>  3040: readlink("/usr/bin/cc","powerpc64-portbld-freebsd12.0-gcc",1023) =
=3D 33 (0x21)
>  3040: lstat("/usr/bin/powerpc64-portbld-freebsd12.0-gcc",{ mode=3D-r-xr-=
xr-x ,inode=3D21028101,size=3D2628488,blksize=3D32768 }) =3D 0 (0x0)
>  3042: execve("/usr/bin/as",0x506600c8,0x50668000) =3D 8 (0x8)
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld"=
,0xffffffffffffd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-gnm",0xffffffffffffd2=
b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-nm",0xffffffffffffd2b=
8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-gstrip",0xfffffffffff=
fd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-strip",0xffffffffffff=
d2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/cc",{ mode=3D-r-xr-xr-x ,inode=3D21028101,size=3D26=
28488,blksize=3D32768 }) =3D 0 (0x0)
>  3043: access("/usr/bin/cc",X_OK)		 =3D 0 (0x0)

By contrast what is in the file system for the failing references above (pd,
nm, strip) is:

> # find / -name "*ld" -print | grep "[/-]ld$"
> /usr/src/contrib/netbsd-tests/usr.bin/ld
> /usr/src/contrib/binutils/ld
> /usr/src/gnu/usr.bin/binutils/ld
> /usr/bin/ld
> /usr/ports/devel/bcc/files/patch-ld
> /usr/powerpc64-freebsd/bin/ld

Compare that last to what the stat from the truss run shows:

> /usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld


> # find / -name "*gnm" -print | grep "[/-]gnm$"

(Yep: no gnm: nm used instead.)

> # find / -name "*nm" -print | grep "[/-]nm$"
> /usr/src/contrib/llvm/tools/llvm-nm
> /usr/src/contrib/elftoolchain/nm
> /usr/src/usr.bin/clang/llvm-nm
> /usr/src/usr.bin/nm
> /usr/bin/nm
> /usr/bin/llvm-nm
> /usr/bin/powerpc64-portbld-freebsd12.0-gcc-nm

Compare that last to what the stat from the truss run shows:

> /usr/bin/powerpc64-portbld-freebsd12.0-nm


> # find / -name "*gstrip" -print | grep "[/-]gstrip$"

(Yep: no gstrip: strip used instead.)

> # find / -name "*strip" -print | grep "[/-]strip$"
> /usr/bin/strip

Compare that to what the stat from the truss run shows:

> /usr/bin/powerpc64-portbld-freebsd12.0-strip


In my context the system cross build made its own powerpc64
binutils. /usr/bin/strip is not from base/binutils :

> # zcat FreeBSD-binutils-2.25.1_3,1.txz | tar -tf - | grep strip
> #

(No match.)


So adding what is missing (result shown):

> # ls -lt /usr/bin/ | head
> total 608956
> lrwxr-xr-x   1 root  wheel         14 Nov  9 05:38 powerpc64-portbld-free=
bsd12.0-strip -> /usr/bin/strip
> lrwxr-xr-x   1 root  wheel         36 Nov  9 05:38 powerpc64-portbld-free=
bsd12.0-nm -> powerpc64-portbld-freebsd12.0-gcc-nm
> lrwxr-xr-x   1 root  wheel         29 Nov  9 05:19 powerpc64-portbld-free=
bsd12.0-powerpc64-freebsd-ld -> /usr/powerpc64-freebsd/bin/ld
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 c++ -> powerpc64-portb=
ld-freebsd12.0-g++
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 cc -> powerpc64-portbl=
d-freebsd12.0-gcc
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 cpp -> powerpc64-portb=
ld-freebsd12.0-cpp
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 g++ -> powerpc64-portb=
ld-freebsd12.0-g++
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 gcc -> powerpc64-portb=
ld-freebsd12.0-gcc
> lrwxr-xr-x   1 root  wheel         34 Nov  8 21:51 gcov -> powerpc64-port=
bld-freebsd12.0-gcov
> #=20


leads to ld being found in a cc but ld not finding the libraries it needs,
here:

> # cc main.c
> /usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld: cannot find =
crt1.o: No such file or directory
> /usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld: cannot find =
crti.o: No such file or directory
> /usr/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld: cannot find =
crtbegin.o: No such file or directory
> collect2: error: ld returned 1 exit status

In the file system are the following (more than just crt1.o , crti.o , and
crtbegin.o shown):

> # find / -name "*crt*.o" -print
> /usr/lib/crtend.o
> /usr/lib/crti.o
> /usr/lib/Scrt1.o
> /usr/lib/crtbegin.o
> /usr/lib/crtbeginT.o
> /usr/lib/crtn.o
> /usr/lib/crtendS.o
> /usr/lib/crtbeginS.o
> /usr/lib/crt1.o
> /usr/lib/crtsavres.o
> /usr/lib/gcrt1.o

"truss -f cc main.cc" shows that one of

/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/
or:
/usr/powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/
or:
/usr/powerpc64-portbld-freebsd12.0/lib/

is expected in order to find crt1.o or crti.o or crtbegin.o or crtend.o or
crtn.o :
(I did any ../ collapsing above)

> # truss -f cc main.c 2>&1 | grep crt
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/crt1.o",R=
_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/cr=
t1.o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/crt1.o",R_OK) ERR#2 'No such file or d=
irectory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/crti.o",R=
_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/cr=
ti.o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/crti.o",R_OK) ERR#2 'No such file or d=
irectory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/crtbegin.=
o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/cr=
tbegin.o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/crtbegin.o",R_OK) ERR#2 'No such file =
or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/crtend.o"=
,R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/cr=
tend.o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/crtend.o",R_OK) ERR#2 'No such file or=
 directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/crtn.o",R=
_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/cr=
tn.o",R_OK) ERR#2 'No such file or directory'
>  3138: access("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/../../../=
../powerpc64-portbld-freebsd12.0/lib/crtn.o",R_OK) ERR#2 'No such file or d=
irectory'
>  3142: open("crt1.o",O_RDONLY,0666)		 ERR#2 'No such file or directory'
>  3142: write(2,"crt1.o",6)			 =3D 6 (0x6)
>  3142: open("crti.o",O_RDONLY,0666)		 ERR#2 'No such file or directory'
>  3142: write(2,"crti.o",6)			 =3D 6 (0x6)
>  3142: open("crtbegin.o",O_RDONLY,0666)		 ERR#2 'No such file or director=
y'
>  3142: write(2,"crtbegin.o",10)			 =3D 10 (0xa)
>  3141: access("crt1.rpo",R_OK)			 ERR#2 'No such file or directory'
>  3141: access("crti.rpo",R_OK)			 ERR#2 'No such file or directory'
>  3141: access("crtbegin.rpo",R_OK)		 ERR#2 'No such file or directory'
>  3141: access("crtend.rpo",R_OK)		 ERR#2 'No such file or directory'
>  3141: access("crtn.rpo",R_OK)			 ERR#2 'No such file or directory'
> crt1.o 3141: write(2,"crt1.o",6)			 =3D 6 (0x6)
> crti.o 3141: write(2,"crti.o",6)			 =3D 6 (0x6)
> crtbegin.o 3141: write(2,"crtbegin.o",10)			 =3D 10 (0xa)


For reference:

> # ls -l /usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/
> total 16
> drwxr-xr-x  2 root  wheel  1024 Nov  9 02:31 include
> drwxr-xr-x  5 root  wheel   512 Nov  9 02:31 include-fixed
> drwxr-xr-x  3 root  wheel   512 Nov  9 02:31 install-tools
> drwxr-xr-x  3 root  wheel   512 Nov  9 02:31 plugin


> # ls -l /usr/powerpc64-portbld-freebsd12.0/
> ls: /usr/powerpc64-portbld-freebsd12.0/: No such file or directory

(So there is no /usr/powerpc64-portbld-freebsd12.0/lib/ or
/usr/powerpc64-portbld-freebsd12.0/lib/powerpc64-portbld-freebsd12.0/5.4.0/=
 to
look in.)

Hacking in:

> # ls -dl /usr/powerpc64-portbld-freebsd12.0
> lrwxr-xr-x  1 root  wheel  4 Nov  9 06:19 /usr/powerpc64-portbld-freebsd1=
2.0 -> /usr

results in cc main.c finally producing an a.out like it should.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-214404-13>