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
Summary: base/gcc: and base/binutils -r424540 for TARGET_ARCH=powerpc64 example: file ...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-10 18:39 UTC by Mark Millard
Modified: 2018-05-27 02:43 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Millard 2016-11-10 18:39:37 UTC
[This is after dealing with mpfr 3.1.4 vs. 3.1.5, adding gcc and g++ commands to my environment, and updating pkg.plist for TARGET_ARCH=powerpc64 . This 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 that 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=FreeBSD: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 what 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"' 
>  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",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/real-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/real-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/5.4.0/collect-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/collect-ld",0xffffffffffffd2f8) 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",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/libexec/gcc/powerpc64-portbld-freebsd12.0/powerpc64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/lib/gcc/powerpc64-portbld-freebsd12.0/5.4.0/powerpc64-freebsd-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",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld",0xffffffffffffd2f8) 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-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/usr/local/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld",0xffffffffffffd2f8) ERR#2 'No such file or directory'
>  2873: stat("/home/markmi/bin/powerpc64-portbld-freebsd12.0-powerpc64-freebsd-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)		 = 0 (0x0)
>  3040: stat("/usr/bin/cc",{ mode=-r-xr-xr-x ,inode=21028101,size=2628488,blksize=32768 }) = 0 (0x0)
>  3040: lstat("/usr/bin/cc",{ mode=lrwxr-xr-x ,inode=21028094,size=33,blksize=32768 }) = 0 (0x0)
>  3040: readlink("/usr/bin/cc","powerpc64-portbld-freebsd12.0-gcc",1023) = 33 (0x21)
>  3040: lstat("/usr/bin/powerpc64-portbld-freebsd12.0-gcc",{ mode=-r-xr-xr-x ,inode=21028101,size=2628488,blksize=32768 }) = 0 (0x0)
>  3040: access("/usr/bin/cc",X_OK)		 = 0 (0x0)
>  3040: stat("/usr/bin/cc",{ mode=-r-xr-xr-x ,inode=21028101,size=2628488,blksize=32768 }) = 0 (0x0)
>  3040: lstat("/usr/bin/cc",{ mode=lrwxr-xr-x ,inode=21028094,size=33,blksize=32768 }) = 0 (0x0)
>  3040: readlink("/usr/bin/cc","powerpc64-portbld-freebsd12.0-gcc",1023) = 33 (0x21)
>  3040: lstat("/usr/bin/powerpc64-portbld-freebsd12.0-gcc",{ mode=-r-xr-xr-x ,inode=21028101,size=2628488,blksize=32768 }) = 0 (0x0)
>  3042: execve("/usr/bin/as",0x506600c8,0x50668000) = 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",0xffffffffffffd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-nm",0xffffffffffffd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-gstrip",0xffffffffffffd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/powerpc64-portbld-freebsd12.0-strip",0xffffffffffffd2b8) ERR#2 'No such file or directory'
>  3043: stat("/usr/bin/cc",{ mode=-r-xr-xr-x ,inode=21028101,size=2628488,blksize=32768 }) = 0 (0x0)
>  3043: access("/usr/bin/cc",X_OK)		 = 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-freebsd12.0-strip -> /usr/bin/strip
> lrwxr-xr-x   1 root  wheel         36 Nov  9 05:38 powerpc64-portbld-freebsd12.0-nm -> powerpc64-portbld-freebsd12.0-gcc-nm
> lrwxr-xr-x   1 root  wheel         29 Nov  9 05:19 powerpc64-portbld-freebsd12.0-powerpc64-freebsd-ld -> /usr/powerpc64-freebsd/bin/ld
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 c++ -> powerpc64-portbld-freebsd12.0-g++
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 cc -> powerpc64-portbld-freebsd12.0-gcc
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 cpp -> powerpc64-portbld-freebsd12.0-cpp
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 g++ -> powerpc64-portbld-freebsd12.0-g++
> lrwxr-xr-x   1 root  wheel         33 Nov  8 21:51 gcc -> powerpc64-portbld-freebsd12.0-gcc
> lrwxr-xr-x   1 root  wheel         34 Nov  8 21:51 gcov -> powerpc64-portbld-freebsd12.0-gcov
> # 


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/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/crt1.o",R_OK) ERR#2 'No such file or directory'
>  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/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/crti.o",R_OK) ERR#2 'No such file or directory'
>  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/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/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/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/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/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/crtn.o",R_OK) ERR#2 'No such file or directory'
>  3142: open("crt1.o",O_RDONLY,0666)		 ERR#2 'No such file or directory'
>  3142: write(2,"crt1.o",6)			 = 6 (0x6)
>  3142: open("crti.o",O_RDONLY,0666)		 ERR#2 'No such file or directory'
>  3142: write(2,"crti.o",6)			 = 6 (0x6)
>  3142: open("crtbegin.o",O_RDONLY,0666)		 ERR#2 'No such file or directory'
>  3142: write(2,"crtbegin.o",10)			 = 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)			 = 6 (0x6)
> crti.o 3141: write(2,"crti.o",6)			 = 6 (0x6)
> crtbegin.o 3141: write(2,"crtbegin.o",10)			 = 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-freebsd12.0 -> /usr

results in cc main.c finally producing an a.out like it should.
Comment 1 Steve Wills freebsd_committer 2018-02-13 17:07:38 UTC
I think this is resolved by the changes in bug 224217. Please confirm.
Comment 2 Mark Millard 2018-02-17 06:07:05 UTC
(In reply to Steve Wills from comment #1)

This will have to wait for experiments on a powerpc64
after having installed what base/binutils and base/gcc
built, probably needing to uninstall the likes of
devel/binutils and devel/powerpc64-gcc first. For
example:

base/binutils vs. devel/powerpc64-binutils
vs.
base/gcc      vs. devel/powerpc64-gcc

3 of the 4 use powerpc64-unknown-freebsd12.0-
prefixes but devel/powerpc64-binutils uses
powerpc64-freebsd- prefixes. (Or did last I
built it on a powerpc64.)

There are the /usr/bin/ vs. /usr/local/bin/
sorts of path differences as well so the
matching names for devel/powerpc64-gcc and
base/gcc make for ties to path order.
Comment 3 Mark Millard 2018-05-27 02:43:52 UTC
(In reply to Mark Millard from comment #2)

I did not get to this before losing access to
the powerpc family members for what will likely
be weeks/months(?). Sorry. [My FreeBSD time has
been very limited in recent months compared
prior recent years.]