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

scons: mingw-w64-gcc fails due to permission denied (bad environment) #235

Closed
elieux opened this issue Apr 29, 2015 · 4 comments · Fixed by #239
Closed

scons: mingw-w64-gcc fails due to permission denied (bad environment) #235

elieux opened this issue Apr 29, 2015 · 4 comments · Fixed by #239

Comments

@elieux
Copy link
Member

elieux commented Apr 29, 2015

During an attempt to build mingw-w64-nsis, I found out scons has a problem with invoking native programs. Scons, in pursue of reproducible builds, tries to clean up the environment before running its detection (configure-like) tests, but mingw-w64-gcc need some of these environment variables to work reliably.

The problem I observed was that gcc was getting permission denied errors while trying to write to C:\Windows. I checked the environment that this gcc had and it was very small (including MSYSTEM, PATH and few other) and lacked TEMP and TMP, so gcc didn't know where to put its temporary files.

The win32.py platform initializer knows this and passes some vars through to the build environment, see https://bitbucket.org/scons/scons/src/d83ec49e287da9d6cfa22d968ebc24ae3ad8882d/src/engine/SCons/Platform/win32.py?at=default#cl-373. I'd say that our msys.py platform script also needs this, but maybe I'm wrong -- is there a better way of compiling with mingw-w64 from MSYS2 using scons?

@Alexpux
Copy link
Member

Alexpux commented Apr 30, 2015

Look into mingw-w64-mesa package.
I don't have issues with scons building it.
Maybe your issue is poor scons scripts for NSIS

@elieux
Copy link
Member Author

elieux commented Apr 30, 2015

Minimalistic example SConstruct:

EnsureSConsVersion(1,2)
defenv = Environment()
Export('defenv')
conf = defenv.Configure()
if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
    print 'zlib is missing!'
    Exit(1)
conf.Finish()

Produces:

$ scons
scons: Reading SConscript files ...
Checking for C library z... no
zlib is missing!

config.log:

file /w/trash/eee/SConstruct,line 7:
    Configure(confdir = .sconf_temp)
scons: Configure: Checking for C library z... 
.sconf_temp/conftest_0.c <-
  |
  |
  |#include "zlib.h"
  |
  |int
  |main() {
  |  
  |return 0;
  |}
  |
gcc -o .sconf_temp/conftest_0.o -c .sconf_temp/conftest_0.c

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Cannot create temporary file in C:\Windows\: Permission denied
scons: Configure: no

@elieux
Copy link
Member Author

elieux commented Apr 30, 2015

As for mesa, its SConstruct has lines like ENV = os.environ that explain why it doesn't suffer from this issue.

@elieux
Copy link
Member Author

elieux commented May 5, 2015

Here is a patch that works for me: https://gist.github.com/elieux/fd63e62fda6a05778004

lututui added a commit to OpenKore/openkore that referenced this issue Oct 22, 2023
On certain gcc distribuitions, if TEMP/TMP are unset, it defaults to writing to the root Windows OS directory (C:/Windows)

msys2/MSYS2-packages#235
lututui added a commit to OpenKore/openkore that referenced this issue Oct 23, 2023
On certain gcc distribuitions, if TEMP/TMP are unset, it defaults to writing to the root Windows OS directory (C:/Windows)

msys2/MSYS2-packages#235
lututui added a commit to OpenKore/openkore that referenced this issue Oct 23, 2023
On certain gcc distribuitions, if TEMP/TMP are unset, it defaults to writing to the root Windows OS directory (C:/Windows)

msys2/MSYS2-packages#235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants