Skip to content

cc-wrapper mktemp invokation incompatible with MacOS #258607

@aherrmann

Description

@aherrmann

Describe the bug

The cc-wrapper invokes mktemp with the --tmpdir flag, which is not supported on MacOS.

Steps To Reproduce

I do not have a short reproducer. However, the issue was observed on this GitHub actions CI run in a cgo context.

  # runtime/cgo
  mktemp: illegal option -- -
  usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
         mktemp [-d] [-q] [-u] -t prefix 

The issue can be resolved by applying the following change to cc-wrapper.sh:

@@ -246,7 +246,7 @@ if [[ -e @out@/nix-support/cc-wrapper-hook ]]; then
 fi

 if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
-    responseFile=$(mktemp --tmpdir cc-params.XXXXXX)
+    responseFile=$(mktemp "${TMPDIR:-/tmp}/cc-params.XXXXXX")
     trap 'rm -f -- "$responseFile"' EXIT
     printf "%q\n" \
        ${extraBefore+"${extraBefore[@]}"} \

Expected behavior

The mktemp error should not have occurred. The code under test used to work, and failed after an update of the nixpkgs revision in use from ea4c80b to 6500b45.

Screenshots

n/a

Additional context

The commit range includes the following two commits that touch on mktemp:

  • 520a544 adds mktemp --tmpdir to the strip setup-hook
  • 6f2b3ba adds mktemp --tmpdir to the cc-wrapper for response file handling
    The latter one seems to be the cause of the issue.

Similar issues were described in #254104 (comment) and numtide/devshell#10 (comment).

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 21.6.0, macOS 12.6.3`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions