Bug 34346 - src/glsl relies on $PWD which can be unset
src/glsl relies on $PWD which can be unset
Status: RESOLVED FIXED
Product: Mesa
Classification: Unclassified
Component: glsl-compiler
git
Other All
: medium normal
Assigned To: Kenneth Graunke
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-16 09:45 UTC by Arkadiusz Miskiewicz
Modified: 2011-02-26 10:31 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arkadiusz Miskiewicz 2011-02-16 09:45:39 UTC
@echo Regenerating builtin_function.cpp...
        $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(PWD)/builtin_compiler > builtin_function.cpp

I'm building in clean environment which has no PWD set. That causes failure.

How to reproduce:
[arekm@carme-pld ~/rpm/BUILD/Mesa-7.11/src/glsl]$ unset PWD
[arekm@carme-pld ~/rpm/BUILD/Mesa-7.11/src/glsl]$ make builtin_function.cpp
Regenerating builtin_function.cpp...
python -t -O -O builtins/tools/generate_builtins.py /builtin_compiler > builtin_function.cpp
Traceback (most recent call last):
  File "builtins/tools/generate_builtins.py", line 196, in <module>
    write_profiles()
  File "builtins/tools/generate_builtins.py", line 107, in write_profiles
    write_profile(filename, profile)
  File "builtins/tools/generate_builtins.py", line 75, in write_profile
    (proto_ir, returncode) = run_compiler([filename])
  File "builtins/tools/generate_builtins.py", line 62, in run_compiler
    p = Popen(command, 1, stdout=PIPE, shell=False)
  File "/usr/share/python2.7/subprocess.py", line 672, in __init__
  File "/usr/share/python2.7/subprocess.py", line 1202, in _execute_child
OSError: [Errno 2] No such file or directory
make: *** [builtin_function.cpp] Błąd 1
zsh: exit 2     make builtin_function.cpp
[arekm@carme-pld ~/rpm/BUILD/Mesa-7.11/src/glsl]$


There is also another issue with this. It fails but partial builtin_function.cpp exists, so all futher make calls will succeed here while these should fail.

Fix for this part of issue is to delete file on failure:
--- Makefile~   2011-02-16 18:13:47.000000000 +0100
+++ Makefile    2011-02-16 18:30:19.210125790 +0100
@@ -208,6 +208,6 @@

 builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
        @echo Regenerating builtin_function.cpp...
-       $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(PWD)/builtin_compiler > builtin_function.cpp
+       $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(PWD)/builtin_compiler > builtin_function.cpp || rm -f builtin_function.cpp

 -include depend
zsh: exit 1     diff -u Makefile{~,}



Fix for both issues is:
--- Makefile~   2011-02-16 18:31:15.419335627 +0100
+++ Makefile    2011-02-16 18:44:53.149316402 +0100
@@ -208,6 +208,6 @@

 builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
        @echo Regenerating builtin_function.cpp...
-       $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(PWD)/builtin_compiler > builtin_function.cpp
+       $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(shell pwd)/builtin_compiler > builtin_function.cpp || rm -f builtin_function.cpp

 -include depend
zsh: exit 1     diff -u Makefile{~,}
Comment 1 Arkadiusz Miskiewicz 2011-02-21 05:45:55 UTC
Partially fixed by #34468. But "|| rm file" part is still needed.
Comment 2 Kenneth Graunke 2011-02-26 10:31:16 UTC
Pushed, thanks.  Closing the bug as it doesn't need to be cherry-picked to 7.10.