Bug 236529 - Mk/Uses/cargo.mk: Corner case makes linking phase to fail
Summary: Mk/Uses/cargo.mk: Corner case makes linking phase to fail
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: FreeBSD Rust Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-14 16:25 UTC by Antonio Huete Jimenez
Modified: 2019-03-14 17:34 UTC (History)
0 users

See Also:


Attachments
log file (4.79 KB, text/plain)
2019-03-14 16:25 UTC, Antonio Huete Jimenez
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.