rust-lang / rust-lang/libc

The which_freebsd detection is cross-compilation unfriendly

Open
#2,061 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug O-bsd S-waiting-on-decision version-support
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

The detection of freebsd version invokes a freebsd-version executable:

https://github.com/rust-lang/libc/blob/5f7c6c1ef93ff4fcfa3d767aac93c2b261c8f140/build.rs#L122-L123

however that only meaningfully works when building on a freebsd host. When building on any other host and targeting a freebsd, libc will always default to targeting a freebsd11.0:

https://github.com/rust-lang/libc/blob/5f7c6c1ef93ff4fcfa3d767aac93c2b261c8f140/build.rs#L26-L34

Thus making it difficult to e.g.

  • Cross-compile a library or binary that relies on freebsd12.0 or freebsd13.0 APIs;
  • CI test other libraries that rely on freebsd12.0 or freebsd13.0 APIs.

Note that adding a freebsd-version executable to the path is not a very viable solution – some builds running in parallel may target other versions of freebsd too.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in build.rs at the linked FreeBSD version detection and follow how target versions are chosen when the host is not FreeBSD. Determine how cross-compilation can select FreeBSD 12.0 or 13.0 APIs without relying on a shared freebsd-version executable; done means those targets can be selected reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.