Bug 236529

Summary: Mk/Uses/cargo.mk: Corner case makes linking phase to fail
Product: Ports & Packages Reporter: Antonio Huete Jimenez <tuxillo>
Component: Individual Port(s)Assignee: FreeBSD Rust Team <rust>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
log file none

Description Antonio Huete Jimenez 2019-03-14 16:25:01 UTC
Created attachment 202856 [details]
log file

Hi,

In Mk/Uses/cargo.mk there is this, line 65'ish:

[...]
        RUSTC=${LOCALBASE}/bin/rustc \
        RUSTDOC=${LOCALBASE}/bin/rustdoc \
        RUSTFLAGS="${RUSTFLAGS} -C linker=${CC:Q} ${LDFLAGS:S/^/-C link-arg=/}"
[...]

RUSTFLAGS will end up being '-C linker=cc -C link-arg=' in case LDFLAGS is empty. This shouldn't be a problem and in fact for clang it is not, it will just ignore the "" parameter passed to the '-C linker' command.

But for gcc it is a problem, it will ENOENT because rustc will pass a "", coming from the empty LDFLAGS as explained above.

Example (from DragonFly BSD's DPorts) attached to this PR.

Regards,
Antonio Huete
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-03-14 17:32:19 UTC
A commit references this bug:

Author: jbeich
Date: Thu Mar 14 17:31:46 UTC 2019
New revision: 495724
URL: https://svnweb.freebsd.org/changeset/ports/495724

Log:
  USES=cargo to omit -C link-arg if LDFLAGS is empty

  DPorts overrides USE_GCC logic and doesn't opt in into SSP_CFLAGS, so
  its LDFLAGS are empty by default.

  PR:		236529
  Reported by:	Antonio Huete Jimenez

Changes:
  head/Mk/Uses/cargo.mk
Comment 2 Jan Beich freebsd_committer freebsd_triage 2019-03-14 17:34:43 UTC
Sorry, I was under impression ${LDFLAGS:S/^/foo/} won't expand if LDFLAGS is empty. Try again and reopen if this is still a problem.