Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 282934 - Bootstrapping on Snow Leopard: libperl-5.8.8-r2 fails to compile in toke.c
Summary: Bootstrapping on Snow Leopard: libperl-5.8.8-r2 fails to compile in toke.c
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: AMD64 OS X
: High blocker
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-27 16:50 UTC by Michael
Modified: 2009-09-12 14:43 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Emerge log for libperl (libperl emerge log.txt,22.70 KB, text/plain)
2009-09-01 21:23 UTC, Joe Gallo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2009-08-27 16:50:46 UTC
When I am supposed to emerge portage, it fails while trying to emerge libperl.

`sh  cflags "optimize='-march=nocona'" toke.o` "-fPIC" toke.c
	  CCCMD =  x86_64-apple-darwin9-gcc -DPERL_CORE -c -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement -march=nocona  -Wall
toke.c: In function 'S_scan_formline':
toke.c:10542: error: invalid operands to binary + (have 'char *' and 'char *')
toke.c:10542: error: lvalue required as unary '&' operand
toke.c:10542: error: lvalue required as unary '&' operand
{standard input}:unknown:Undefined local symbol LC16
{standard input}:unknown:Undefined local symbol LC212
make: *** [toke.o] Error 1
 * ERROR: sys-devel/libperl-5.8.8-r2 failed:
 *   Unable to make libperl.dylib

I've tried using a custom ebuild that removes -DPERL_CORE and -DPERL_DARWIN, which gets me farther into the build, but then it fails in Makefile.SH on the $eunicefix line because $eunicefix is undefined. Removing that line gives me another error:
	  CCCMD =   -c  -march=nocona 
/pfx/tmp/usr/bin/bash: -c: command not found


Reproducible: Always

Steps to Reproduce:
1. emerge libperl
2.
3.




I'm bootstrapping prefix under Mac OS X Snow Leopard. I'm on a case-insensitive file system (I will try on case-sensitive soon). I can provide more info if needed, and am here to try your suggestions, since many don't have access to this build yet.
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-08-27 17:26:49 UTC
What step of what document are you on?
Comment 2 Michael 2009-08-27 17:42:09 UTC
(In reply to comment #1)
> What step of what document are you on?
> 

Code 1.11
env FEATURES="-collision-protect" emerge --oneshot portage

http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml
Comment 3 Fabian Groffen gentoo-dev 2009-08-28 07:00:33 UTC
you're on Snow Leopard, why isn't your CHOST *-darwin10?
Comment 4 Michael 2009-08-28 19:34:00 UTC
(In reply to comment #3)
> you're on Snow Leopard, why isn't your CHOST *-darwin10?
> 

Alright, I've grabbed the 10.6 profile from CVS, and now gcc-apple won't even compile. Maybe I should wait a bit before the profile and ebuilds get sorted out?

...
nm: can't open file: .libs/compatibility.o (No such file or directory)
lots of file not found errors of .libs/xxx.o where xxx.o is actually in cwd.
....
nm error at /pfx/var/tmp/portage/sys-devel/gcc-apple-4.2.1_p5574/work/libstdcxx-16/libstdcxx/libstdc++-v3/scripts/make_exports.pl line 130.
Comment 5 Fabian Groffen gentoo-dev 2009-08-29 07:25:37 UTC
you'll have to bootstrap using latest_tree, instead of tree

that'll get you the profile and updates ebuilds
Comment 6 Michael 2009-08-29 17:36:16 UTC
(In reply to comment #5)
> you'll have to bootstrap using latest_tree, instead of tree
> 
> that'll get you the profile and updates ebuilds
> 

Thanks, now gcc compiles, but I'm right back to step 1. libperl fails in toke.c. With various sed replacements, it still fails later in the build. 
Comment 7 Sören Kuklau 2009-08-30 16:07:18 UTC
I have the same problem on Snow Leopard with x86 (not x64). I tried bootstrapping using tree or latest_tree, and using the 10.5/x86 profile as well as a custom 10.6/x86 profile (largely the same but with CHOST ending with darwin10).

bootstrap-prefix.sh r50036; portage prefix snapshot 20090829. In addition, perl apparently fails to detect my rand() function:

Checking to see how many bits your rand() function produces...
Configure: line 18013: try: command not found
How many bits does your rand() function produce?

(None of the answers appear to affect the later error.)
Comment 8 Fabian Groffen gentoo-dev 2009-08-30 18:26:49 UTC
right, same thing everywhere.  Need to find a fix for that.
Comment 9 Joe Gallo 2009-09-01 21:23:28 UTC
Created attachment 202903 [details]
Emerge log for libperl

Interesting stuff going on at lines 144-165 or so, it looks like the problem might be related to ar not working right (/me is a newb, though, so don't bite, please.)
Comment 10 Pavel Volkovitskiy 2009-09-04 23:35:49 UTC
it builds if i add "-Dnm=/usr/bin/nm" to Configure

so looks like this is binutils-apple issue
(Configure tries with /opt/gentoo/usr/bin/nm if you don't specify -Dnm)
Comment 11 Fabian Groffen gentoo-dev 2009-09-05 07:02:24 UTC
hmmm, aha, that's interesting.  unfortunately 10.6's cctools and ld64 don't compile due to missing stuff :(
Comment 12 Pavel Volkovitskiy 2009-09-05 11:23:04 UTC
is that possible to use pre-compiled toolchain from osx?
Comment 13 Fabian Groffen gentoo-dev 2009-09-07 19:13:58 UTC
this would mean 32-bits bootstraps would/should be ok
Comment 14 Fabian Groffen gentoo-dev 2009-09-07 19:19:39 UTC
perl-5.8.9 fails too? can anyone try?
Comment 15 Pavel Volkovitskiy 2009-09-07 20:49:46 UTC
same error with 5.8.9:

/opt/gentoo/usr/bin/nm didn't seem to work right. Trying /opt/gentoo/usr/bin/ar instead...
ar: /usr/lib/libc.dylib: Inappropriate file type or format
/opt/gentoo/usr/bin/ar didn't seem to work right.
Maybe this is a Cray...trying bld instead...
Configure: line 7587: bld: command not found
Configure: line 7590: bld: command not found
ar: /usr/lib/libdbm.dylib: Inappropriate file type or format
Configure: line 7590: bld: command not found
ar: /usr/lib/libdl.dylib: Inappropriate file type or format
Configure: line 7590: bld: command not found
ar: /usr/lib/libm.dylib: Inappropriate file type or format
Configure: line 7590: bld: command not found
ar: /usr/lib/libutil.dylib is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: /usr/lib/libutil.dylib: Inappropriate file type or format

and compilation fails with:
toke.c: In function 'Perl_yylex':
toke.c:5516: error: lvalue required as unary '&' operand
toke.c:5516: error: lvalue required as unary '&' operand
Comment 16 Pavel Volkovitskiy 2009-09-07 20:51:28 UTC
also i was able to bootstrap system (with small python/perl patches for 10.6) using binutils symlinked from /usr (ie binaries from apple)
Comment 17 Fabian Groffen gentoo-dev 2009-09-08 08:37:24 UTC
right, you can of course use native-cctools to use the system installed ld, ar, nm, etc.

is there any log that can make it more clear why perl thinks nm isn't working right?
Comment 18 Pavel Volkovitskiy 2009-09-08 09:46:25 UTC
/opt/gentoo/usr/bin/nm /usr/lib/libc.dylib
/opt/gentoo/usr/bin/nm: for architecture x86_64 object: /usr/lib/libc.dylib malformed object (unknown load command 5)

btw, didn't saw native-cctools, thx! (i symlinked native binutils to try)
Comment 19 Sören Kuklau 2009-09-08 17:03:20 UTC
(In reply to comment #18)
> /opt/gentoo/usr/bin/nm /usr/lib/libc.dylib
> /opt/gentoo/usr/bin/nm: for architecture x86_64 object: /usr/lib/libc.dylib
> malformed object (unknown load command 5)

I still suspect (and the above log appears to confirm this) that nm is expecting a binary segment, and getting a Universal Binary (i.e. multiple segments). AFAICT, the ebuild removes UB support from apple-cctools. Either use a UB-aware nm, or run libtool or lipo first.
Comment 20 Fabian Groffen gentoo-dev 2009-09-08 17:14:39 UTC
how does the ebuild remove FAT binary support?
Comment 21 Sören Kuklau 2009-09-08 17:20:06 UTC
(In reply to comment #20)
> how does the ebuild remove FAT binary support?

Well, that's how I interpreted this comment from binutils-apple-3.1.2-r1.ebuild:

	# we don't do universal binaries
	((++c)); rm -rf blank-stubs;

I see now that that's apparently only for ld, though, not ar.
Comment 22 Pavel Volkovitskiy 2009-09-08 19:09:35 UTC
FYI bigger part of output:
Where is your C library? [/usr/lib/libc.dylib]  
Extracting names from the following files for later perusal:
        /usr/lib/libc.dylib
        /usr/lib/libdbm.dylib
        /usr/lib/libdl.dylib
        /usr/lib/libm.dylib
        /usr/lib/libutil.dylib
This may take a while................../opt/gentoo/usr/bin/nm didn't seem to work right. Trying /opt/gentoo/usr/bin/ar instead...
ar: /usr/lib/libc.dylib is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: /usr/lib/libc.dylib: Inappropriate file type or format
/opt/gentoo/usr/bin/ar didn't seem to work right.
Maybe this is a Cray...trying bld instead...
Configure: line 7392: bld: command not found
Configure: line 7395: bld: command not found
ar: /usr/lib/libdbm.dylib: Inappropriate file type or format
Configure: line 7395: bld: command not found
ar: /usr/lib/libdl.dylib is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: /usr/lib/libdl.dylib: Inappropriate file type or format
Configure: line 7395: bld: command not found
ar: /usr/lib/libm.dylib is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: /usr/lib/libm.dylib: Inappropriate file type or format
Configure: line 7395: bld: command not found
ar: /usr/lib/libutil.dylib: Inappropriate file type or format
Comment 23 Pavel Volkovitskiy 2009-09-08 19:11:35 UTC
libc.dylib:
file /usr/lib/libSystem.B.dylib: /usr/lib/libSystem.B.dylib: Mach-O fat file with 3 architectures
Comment 24 Fabian Groffen gentoo-dev 2009-09-08 19:13:31 UTC
I do not exclude my 64-bits patching to binutils-apple to broke nm.  Maybe because your libs only contain 3 arches, and on leopard 4 the problem only now gets noticed (alignment issues).

I think this is not so much a problem with perl, but with our nm :(
Comment 25 Pavel Volkovitskiy 2009-09-08 19:24:14 UTC
python broken too:
....
ranlib: archive member: libpython2.6.a(threadmodule.o) offset in archive not a multiple of 8 (must be since member is an 64-bit object file)
x86_64-apple-darwin10-ranlib libpython2.6.a
/opt/gentoo/usr/bin/install -c -d -m 755 Python.framework/Versions/2.6
if test ""; then \
                x86_64-apple-darwin10-gcc -o Python.framework/Versions/2.6/Python  -dynamiclib \
                        -isysroot "" \
                        -all_load libpython2.6.a -Wl,-single_module \
                        -install_name /opt/gentoo/usr/lib/Python.framework/Versions/2.6/Python \
                        -compatibility_version 2.6 \
                        -current_version 2.6; \
        else \
                libtool -o Python.framework/Versions/2.6/Python -dynamic  libpython2.6.a \
                         -lSystem -lSystemStubs -install_name /opt/gentoo/usr/lib/Python.framework/Versions/2.6/Python -compatibility_version 2.6 -current_version 2.6 ;\
        fi
libtool: for architecture x86_64 object: /usr/lib/libSystem.dylib malformed object (unknown load command 5)
libtool: for architecture: (null) file: -lSystem is not an object file (not allowed in a library)
libtool: for architecture i386 object: /usr/lib/libSystem.dylib malformed object (unknown load command 5)
make: *** [Python.framework/Versions/2.6/Python] Error 1
Comment 26 Fabian Groffen gentoo-dev 2009-09-08 19:26:13 UTC
right, that clearly indicates an offset problem, as load_commands are right in the Mach-O header, and differ for 32-bits and 64-bits objects.
Comment 27 Fabian Groffen gentoo-dev 2009-09-08 19:29:06 UTC
Another option which sounds much more plausible to me is that the linker is too old.  Apple added a new load_command, put that in the object, and since we have the leopard linker here it doesn't know this load_command and complains.

problem is that I can't compile the linker sources since Apple forgot to include something (libunwind, Apple style).

perhaps native-cctools is the only solution for the moment.
Comment 28 Pavel Volkovitskiy 2009-09-10 20:50:41 UTC
maybe it's possible to get plain libunwind from gnu gcc?
Comment 29 Fabian Groffen gentoo-dev 2009-09-11 06:15:45 UTC
If only that was /it/.  Apple uses something that has includes like this <libunwind/[A-Z][a-z]+>, see http://www.opensource.apple.com/source/ld64/ld64-95.2.12/src/ld/MachOReaderRelocatable.hpp, for instance:
#include <libunwind/DwarfInstructions.hpp>

now I can't find such file anywhere, but if you have clues/ideas, let me know!
Comment 30 Fabian Groffen gentoo-dev 2009-09-12 14:08:28 UTC
good news: binutils-apple-3.2 provides a nm that works correctly.  I excluded ld64 from SN in that build, hopefully we can add it somewhere in the future.
Comment 31 Fabian Groffen gentoo-dev 2009-09-12 14:43:33 UTC
binutils-apple-3.2 is unmasked now, and fixes this particular bootstrap problem (the next is openssh :()