Re: base/binutils vs. /usr/local/lib references and also: undefined reference to `pthread_create' (powerpc64 targeting example)

Mark Millard via freebsd-ppc <[email protected]>
Newsgroups gmane.os.freebsd.devel.ppc,gmane.os.freebsd.devel.toolchain
Message-ID <[email protected]>
[Actually devel/gettext-tools is a build time dependency: it should not be using
libtool: link: /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc --sysroot=. . .
It looks like the /usr/local/lib references are correct but the wrong linker was
being used. About 5 other ports have a similar status for making base/binutils
as a cross build.]

On 2018-Oct-5, at 11:00 PM, Mark Millard <marklmi at yahoo.com> wrote:

> In trying to follow the base/binutils part of https://wiki.freebsd.org/ExternalGCC
> (or /usr/ports/base/README) for targeting powerpc64 I got:
> 
> ( My /etc/make.conf has: WRKDIRPREFIX?=/wrkdirs .)
> 
> # cd ../../base/binutils/
> # make CROSS_TOOLCHAIN=powerpc64-gcc CROSS_SYSROOT=/usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld package
> . . .

Note: This should involve building devel/gettext-tools targetting amd64
(the host environment in this example) because devel/gettext-tools is
a build-time dependency, not to be run on the target system.

> --- recode-sr-latin ---
> /bin/sh ../libtool  --tag=CC    --mode=link /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc --sysroot=/usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld   -O2 -pipe  -DLIBICONV_PLUG -g -fno-strict-aliasing    -o recode-sr-latin recode_sr_latin-recode-sr-latin.o  recode_sr_latin-filter-sr-latin.o ../gnulib-lib/libgettextlib.la  ../intl/libintl.la    -L/usr/local/lib

So the following is wrong:

--mode=link /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc --sysroot=/usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld

here and analogous points are later.

> --- cldr_plurals-cldr-plural.o ---
> . . .
> --- recode-sr-latin ---
> libtool: link: /usr/local/bin/powerpc64-unknown-freebsd12.0-gcc --sysroot=/usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld -O2 -pipe -DLIBICONV_PLUG -g -fno-strict-aliasing -o .libs/recode-sr-latin recode_sr_latin-recode-sr-latin.o recode_sr_latin-filter-sr-latin.o  ../gnulib-lib/.libs/libgettextlib.so /wrkdirs/usr/ports/devel/gettext-tools/work/gettext-0.19.8.1/gettext-tools/intl/.libs/libintl.so -L/usr/local/lib ../intl/.libs/libintl.so -lm -lncurses -Wl,-rpath -Wl,/usr/local/lib
> --- hostname ---
> . . .
> --- recode-sr-latin ---
> /wrkdirs/usr/ports/devel/gettext-tools/work/gettext-0.19.8.1/gettext-tools/intl/.libs/libintl.so: undefined reference to `pthread_create'

devel/gettext-tools has an option to enable/disable building for thread
use, with a default of enabled.

> collect2: error: ld returned 1 exit status
> *** [recode-sr-latin] Error code 1
> 
> make[16]: stopped in /wrkdirs/usr/ports/devel/gettext-tools/work/gettext-0.19.8.1/gettext-tools/src
> 
> 
> The use of -L/usr/local/lib and -Wl,-rpath -Wl,/usr/local/lib look
> suspect for such cross builds:
> 
> # ls /usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld/usr/local/lib/
> ls: /usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld/usr/local/lib/: No such file or directory

I went the wrong direction with this: it should not be a powerpc64
targeted operation and so /usr/local/lib appears to be a correct
aspect.

> Then there is also: undefined reference to `pthread_create'. Is there
> a missing -pthread or some such? (Or is the /usr/local/lib reference
> a cause?) [FYI: The earlier pkg build seem to have worked.]

This sort of aspect might still apply.

> Looks like this way of getting to 12 or later for powerpc64 without
> use of gcc 4.2.1 is currently blocked. (The issue may not be limited
> to powerpc64.)

May be if devel/gettext-tools had been pre-built and installed
before trying the CROSS_TOOLCHAIN=powerpc64-gcc
CROSS_SYSROOT=/usr/obj/DESTDIRs/xtcgcc-powerpc64-installworld
based build activity it would have been okay?

[I try such later below and report on the results.]

There are no words on https://wiki.freebsd.org/ExternalGCC or
in /usr/ports/base/README for such special build-sequence
instructions.

> (It is also unclear how the process involving base/* mixes with doing
> later FreeBSD updates from source --including any use of a delete-old
> step if WITHOUT_BINUTILS= is used at the time. For the cross buildworld
> itself it is not clear what options are intended.)
> 
> 
> 
> Notes about some typos on: https://wiki.freebsd.org/ExternalGCC
> 
> /usr/ports/devel/ports-mgmt/pkg should be:
> /usr/ports/ports-mgmt/pkg
> 
> 3 examples of CROSS_TOOCLAHIN should be:
> CROSS_TOOLCHAIN
> 
> 
> Notes about the /usr/ports/base/README :
> 
> No mention is made of the pkg build so that it can be
> set up on the target. Only https://wiki.freebsd.org/ExternalGCC
> has that information. /usr/ports/base/README does not
> reference https://wiki.freebsd.org/ExternalGCC either.

There may be more material needed on one or both of
https://wiki.freebsd.org/ExternalGCC and/or
/usr/ports/base/README for the likes of how/when
things like devel/gettext-tools should be built
vs. when CROSS_TOOLCHAIN=. . . CROSS_SYSROOT= . . .
builds build steps should be done.

There may be more material needed about the build
options to use for various steps, such as if
devel/gettext-tools should have threading enabled
vs. disabled.

The following seem to have a similar status to
devel/gettext-tools:

math/gmp
math/mpfr
devel/bison
devel/m4 (indirectly via devel/bison)
devel/gmake
devel/gettext-tools (just for list completeness) 

in that each is a build dependency for
devel/binutils variants, such as base/binutils .

With those 6 ports pre-installed as host
non-cross-build material (amd64 here) the cross
build/package of base/binutils worked, given that
it was not already installed as host material.

[In thinking about it I think I made similar notes
and sent them out on the lists long ago. base/*
have improved much since then: I reported a
lot more then as well that does not apply now.]

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.