Bug 230018 - devel/libtool: Baked in compile time CC/LD paths (/nxb-bin/ on armv6/armv7) with poudriere
Summary: devel/libtool: Baked in compile time CC/LD paths (/nxb-bin/ on armv6/armv7) w...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-24 16:48 UTC by Val Packett
Modified: 2022-12-25 22:18 UTC (History)
4 users (show)

See Also:
tijl: maintainer-feedback+
koobs: maintainer-feedback? (bdrewery)


Attachments
patch (791 bytes, patch)
2022-04-08 16:15 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Val Packett 2018-07-24 16:48:34 UTC
Official FreeBSD packages for 32-bit ARM are built using cross-compilation, and the ARM system root in that case is /nxb-bin/.

So these paths are baked directly into libtool:

$ grep nxb-bin /usr/local/bin/libtool
LTCC="/nxb-bin/usr/bin/cc"
sys_lib_search_path_spec="/nxb-bin/usr/lib/clang/6.0.0 /usr/lib "
LD="/nxb-bin/usr/bin/ld"
CC="/nxb-bin/usr/bin/cc"
LD="/nxb-bin/usr/bin/ld"
CC="/nxb-bin/usr/bin/c++"
LD="/nxb-bin/usr/bin/ld"
LD="/nxb-bin/usr/bin/ld"

Which results in surprising errors when building stuff natively on arm:

libtool: link: /nxb-bin/usr/bin/cc -shared  -fPIC -DPIC  .libs/sgc.o      -Wl,-soname -Wl,libmzgc-6.12.so -o ../.libs/libmzgc-6.12.so                                            
eval: /nxb-bin/usr/bin/cc: not found

I'm not sure what's the right solution for this. Make a symlink from /nxb-bin to / on arm installs? Ugly. s|/nxb-bin||g on the generated libtool package? Will break the cross-compilation environment I think.

Actually, shouldn't all libtool invocations override these variables, so that both cross and native always work?
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2019-06-02 12:56:45 UTC
Is this still a problem?

I would build packages without setting systemroot and put whatever is in /nxb-bin/usr/bin/ in /usr/bin.
Comment 2 Mikael Urankar freebsd_committer freebsd_triage 2019-06-02 13:10:19 UTC
Yes the issue is still present.
poudriere still creates a make.nxb.conf [1] instead of creating hardlinks for the toolchain (like it's done for some utilities [2]).

[1] https://github.com/freebsd/poudriere/blob/master/src/share/poudriere/common.sh#L2214
[2] https://github.com/freebsd/poudriere/blob/master/src/share/poudriere/common.sh#L2233
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2019-06-02 13:28:35 UTC
(In reply to mikael.urankar from comment #2)
Ok, then please discuss this issue with the poudriere devs.  I cannot address this in devel/libtool.  The libtool script is generated during build for the compiler used during build.  It cannot reliably use another compiler.
Comment 4 Robert Clausecker freebsd_committer freebsd_triage 2021-10-16 10:12:17 UTC
Had the same issue right now.  Seems like the assumption that the C compiler is the same at libtool build time and libtool use time is shaky.  Maybe it's an inherent defect of libtool.

As a fix, can't you change the libtool port Makefile to always use CC=/usr/bin/cc, direspecting how CC is set?  Maybe guard this behind an option in case the user truly wants a non standard CC.

I've gone ahead and filed an issue with Poudriere.  However I believe this can and should be fixed in devel/libtool, too.

https://github.com/freebsd/poudriere/issues/929
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2021-10-17 00:43:24 UTC
See Also: https://cmake.org/pipermail/cmake/2015-September/061505.html
Comment 6 Tijl Coosemans freebsd_committer freebsd_triage 2022-04-08 16:15:06 UTC
Created attachment 233069 [details]
patch

Can someone try this patch?
Comment 7 commit-hook freebsd_committer freebsd_triage 2022-12-25 22:15:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5325ea5ae199c461c0dce63075d2d90c095b80fd

commit 5325ea5ae199c461c0dce63075d2d90c095b80fd
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2022-04-08 14:31:53 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2022-12-25 22:12:15 +0000

    devel/libtool: Fix cross compiled packages

    The libtool script is generated for a given compiler so Poudriere cannot
    use a cross compiler.

    lang/python* ports have a similar problem.

    PR:             230018

 devel/libtool/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)