Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpsd: fix cross-compilation #182175

Merged
merged 1 commit into from Aug 19, 2022
Merged

gpsd: fix cross-compilation #182175

merged 1 commit into from Aug 19, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jul 20, 2022

Description of changes

Builds of pkgsCross.*.gpsd currently fail with:

scons: Reading SConscript files ...
scons version: 4.1.0
scons is running under Python version: 3.10.5.final.0
gpsd version: 3.23.1
This system is: linux
KeyError: 'CCVERSION':
  File "/build/gpsd-3.23.1/SConstruct", line 69:
    SConscript('SConscript',
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 654:
    return method(*args, **kw)
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/build/gpsd-3.23.1/gpsd-3.23.1/SConscript", line 883:
    announce("cc is %s, version %s" % (env['CC'], env['CCVERSION']))
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Environment.py", line 388:
    return self._dict[key]

The derivation already includes a patch that fiddles with the env array; this might have something to do with it.

Fortunately CCVERSION is never used for anything other than printing during the build. So we can replace CCVERSION with CC.

With this commit, pkgsCross.mips64el-linux-gnuabi64.gpsd and pkgsCross.powernv.gpsd build correctly on x86_64.

Things done
  • Built on platform(s)
    • powerpc-linux (cross from x86_64-linux)
    • mips64el-linux (cross from x86_64-linux)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@ghost

This comment was marked as duplicate.

@bjornfor bjornfor added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jul 20, 2022
@ghost

This comment was marked as duplicate.

@ghost

This comment was marked as resolved.

@squalus
Copy link
Member

squalus commented Jul 21, 2022

nix-build . -A pkgsCross.aarch64-multiplatform.gpsd (with guiSupport = false) fails for me:

moving /nix/store/3jrcmbx1ra2lrlf8p5ml8rmk92lwkxw5-gpsd-aarch64-unknown-linux-gnu-3.23.1/sbin/* to /nix/store/3jrcmbx1ra2lrlf8p5ml8rmk92lwkxw5-gpsd-aarch64-unknown-linux-gnu-3.23.1/bin
rm: missing operand
Try 'rm --help' for more information.

@ghost
Copy link
Author

ghost commented Jul 24, 2022

@squalus, you need to merge #182173 first

@ghost
Copy link
Author

ghost commented Jul 28, 2022

Okay, #182173 merged, so this can be tested now. I've pushed an additional patch with a top-level entry for gpsd {guiSupport=false;}, so now:

@ofborg build pkgsCross.mips64el-linux-gnuabi64.gpsd-nogui

I can revert the addition of gpsd-nogui if having it in top-level is inappropriate.

@ghost

This comment was marked as duplicate.

@ghost
Copy link
Author

ghost commented Jul 28, 2022

@ghost ghost requested a review from bjornfor July 28, 2022 20:47
Copy link
Member

@sorki sorki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! Thank you! I've wasted many hours trying to fix this.

@ghost ghost marked this pull request as draft August 19, 2022 05:41
@ghost ghost marked this pull request as ready for review August 19, 2022 05:41
@ghost ghost requested review from smancill and removed request for bjornfor and rasendubi August 19, 2022 05:41
@ghost
Copy link
Author

ghost commented Aug 19, 2022

I have updated the commit message.

@ofborg ofborg bot requested review from bjornfor and rasendubi August 19, 2022 05:50
Prior to this commit, builds of `pkgsCross.*.gpsd` were failing.

`gpsd` expects `CCVERSION` to be set, and fails if it is not set.
Scons does not guarantee that `CCVERSION` will be set, nor does it
specify under what circumstances it will or will not be set: "This may
or may not be set, depending on the specific C compiler being used."

  https://scons.org/doc/production/HTML/scons-man.html#cv-CCVERSION

Apparently cross-compilation triggers one of those unspecified
circumstances.  There are several bug reports to scons relating to
this:

  SCons/scons#1723
  https://github.com/SCons/scons/issues?q=is%3Aissue+ccversion+is%3Aclosed

`gpsd` does not use `CCVERSION` for any purpose other than printing a
log message at the start of the build:

  https://gitlab.com/gpsd/gpsd/-/commit/d0558636038e18d90eb886f668ff5004538f7839

This commit modifies the log message, replacing `env['CCVERSION']`
with `env['CC']`, since `CC` is always set when using nixpkgs'
standard builder.

With this commit, `pkgsCross.mips64el-linux-gnuabi64.gpsd` and
`pkgsCross.powernv.gpsd` build correctly on x86_64.  Prior to this
commit, they would fail with:

```
scons: Reading SConscript files ...
scons version: 4.1.0
scons is running under Python version: 3.10.5.final.0
gpsd version: 3.23.1
This system is: linux
KeyError: 'CCVERSION':
  File "/build/gpsd-3.23.1/SConstruct", line 69:
    SConscript('SConscript',
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 654:
    return method(*args, **kw)
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/build/gpsd-3.23.1/gpsd-3.23.1/SConscript", line 883:
    announce("cc is %s, version %s" % (env['CC'], env['CCVERSION']))
  File "/nix/store/0vmqv6f2s8bj2a50gk8g05jcb5scnifb-scons-4.1.0/lib/python3.10/site-packages/SCons/Environment.py", line 388:
    return self._dict[key]
```
@bjornfor bjornfor merged commit fe54853 into NixOS:master Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants