Re: [cfe-users] Adding linker flag `-save-temps` resolves the clang-8 error: "unable to make temporary file"
Hi David, Hi Fang-rui, Just to remind, when I add -save-temps flag, linking works, but without this option it fails with: clang-8: error: unable to make temporary file: No such file or directory clang-8: error: unable to make temporary file: No such file or directory clang-8: error: unable to make temporary file: No such file or directory Here is the output with flags -save-temps, -###: "/usr/bin/clang-8" "-cc1" "-triple" "x86_64-unknown-windows-cygnus" "-S" "-save-temps=cwd" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "my_files\\my_file1.bc" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-momit-leaf-frame-pointer" "-v" "-resource-dir" "/usr/lib/clang/8.0.1" "-fdebug-compilation-dir" "/cygdrive/c/my_projects/prj1/Debug" "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" "-fseh-exceptions" "-fdiagnostics-show-option" "-o" "my_files\\my_file1.s" "-x" "ir" "my_files\\my_file1.bc" "-faddrsig" Here is the output without -save-temps, just -###: "/usr/bin/clang-8" "-cc1" "-triple" "x86_64-unknown-windows-cygnus" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "my_files\\my_file1.bc" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-momit-leaf-frame-pointer" "-v" "-resource-dir" "/usr/lib/clang/8.0.1" "-fdebug-compilation-dir" "/cygdrive/c/my_projects/prj1/Debug" "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" "-fseh-exceptions" "-fdiagnostics-show-option" "-o" "" "-x" "ir" "my_files\\my_file1.bc" "-faddrsig" So the "-o" "my_files\\my_file1.s" vs "-o" "" seems to be the difference. Is there an explanation? Also, some more output with the output with flags -save-temps, -###: "/usr/bin/ld" "-m" "i386pep" "--wrap" "_Znwm" "--wrap" "_Znam" "--wrap" "_ZnwmRKSt9nothrow_t" "--wrap" "_ZnamRKSt9nothrow_t" "--wrap" "_ZdlPv" "--wrap" "_ZdaPv" "--wrap" "_ZdlPvRKSt9nothrow_t" "--wrap" "_ZdaPvKSt9nothrow_t" "-Bdynamic" "--tsaware" "-o" "myexecutable" "/usr/lib/crt0.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtbegin.o" "-LC:/mylibraries" "-L/usr/lib/gcc/x86_64-pc-cygwin/10" "-L/usr/x86_64-pc-cygwin/lib" "-L/usr/lib" "-L/usr/lib/w32api" "my_files\\my_file1.o" "my_files\\my_file2.o" " my_files\\my_file3.o" "-lnaturedsp" "-lgcc_s" "-gcc" "-lcygwin" "-ladvapi32" "-lshell32" "-luser32" "-lkernel32" "/usr/lib/default-manifest.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtend.o" and with only -###: "/usr/bin/ld" "-m" "i386pep" "--wrap" "_Znwm" "--wrap" "_Znam" "--wrap" "_ZnwmRKSt9nothrow_t" "--wrap" "_ZnamRKSt9nothrow_t" "--wrap" "_ZdlPv" "--wrap" "_ZdaPv" "--wrap" "_ZdlPvRKSt9nothrow_t" "--wrap" "_ZdaPvKSt9nothrow_t" "-Bdynamic" "--tsaware" "-o" "myexecutable" "/usr/lib/crt0.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtbegin.o" "-LC:/mylibraries" "-L/usr/lib/gcc/x86_64-pc-cygwin/10" "-L/usr/x86_64-pc-cygwin/lib" "-L/usr/lib" "-L/usr/lib/w32api" "" "" "" "-lnaturedsp" "-lgcc_s" "-lgcc" "-lcygwin" "-ladvapi32" "-lshell32" "-luser32" "-lkernel32" "/usr/lib/default-manifest.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtend.o" So, again "my_files\\my_file1.o" "my_files\\my_file2.o" " my_files\\my_file3.o" is lost and substituted with empty strings "" "" "". Does this info help resolve my problem? Danijel On Thu, Aug 13, 2020 at 8:27 PM David Blaikie wrote: > Oh, sorry, I didn't read the question in detail about how -save-temps > was making things work when they otherwise were not. > > If you run clang with -### it'll show the command lines it's using, > which should show you where it's trying to write the files so you can > change that/make them writable. I'm not sure which variable is used to > influence clang's temporary directory choice, though. > > On Thu, Aug 13, 2020 at 11:22 AM Danijel DOMAZET > wrote: > > > > Thanks Fang-rui. > > I still haven't been able to fix the issue, I still use --save-temps, > and that makes linking very slow. > > Why does this error go away when I set --save-temps, any idea?? > > > > > > > > On Thu, Aug 13, 2020 at 7:16 PM Fāng-ruì Sòng > wrote: > >> > >> On Thu, Aug 13, 2020 at 8:59 AM David Blaikie > wrote: > >> > > >> > On Thu, Aug 13, 2020 at 2:59 AM Danijel DOMAZET > >> > wrote: > >> > > > >> > > Thanks David. > >> > > Why do you think this could be about current dir? > >> > > Isn't it about TMP (or TEMP or TMPDIR) environment variables? > >> > >> Neither the driver option -save-temps nor the linker option > >> --save-temps (driver option -Wl,--save-temps) respects > >> TMP/TEMP/TMPDIR. > >> The temporary files are saved relative to the current working > >> directory, which can be changed via -working-directory= > >> > >> > Because I ran it locally, a
Re: [cfe-users] Adding linker flag `-save-temps` resolves the clang-8 error: "unable to make temporary file"
Yep, pretty weird that it tries to write to an empty file name. What's the exact raw clang command you used that printed that cc1 command line? On Mon, Oct 5, 2020 at 6:46 AM Danijel DOMAZET < p-danijel.doma...@devialet.com> wrote: > Hi David, Hi Fang-rui, > > Just to remind, when I add -save-temps flag, linking works, but without > this option it fails with: > > clang-8: error: unable to make temporary file: No such file or directory > clang-8: error: unable to make temporary file: No such file or directory > clang-8: error: unable to make temporary file: No such file or directory > > Here is the output with flags -save-temps, -###: > > "/usr/bin/clang-8" "-cc1" "-triple" "x86_64-unknown-windows-cygnus" "-S" > "-save-temps=cwd" "-disable-free" "-disable-llvm-verifier" > "-discard-value-names" "-main-file-name" "my_files\\my_file1.bc" > "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" > "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" > "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" > "-momit-leaf-frame-pointer" "-v" "-resource-dir" "/usr/lib/clang/8.0.1" > "-fdebug-compilation-dir" "/cygdrive/c/my_projects/prj1/Debug" > "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" > "-fseh-exceptions" "-fdiagnostics-show-option" "-o" "my_files\\my_file1.s" > "-x" "ir" "my_files\\my_file1.bc" "-faddrsig" > > Here is the output without -save-temps, just -###: > > "/usr/bin/clang-8" "-cc1" "-triple" "x86_64-unknown-windows-cygnus" > "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" > "-discard-value-names" "-main-file-name" "my_files\\my_file1.bc" > "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" > "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" > "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" > "-momit-leaf-frame-pointer" "-v" "-resource-dir" "/usr/lib/clang/8.0.1" > "-fdebug-compilation-dir" "/cygdrive/c/my_projects/prj1/Debug" > "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" > "-fseh-exceptions" "-fdiagnostics-show-option" "-o" "" "-x" "ir" > "my_files\\my_file1.bc" "-faddrsig" > > So the "-o" "my_files\\my_file1.s" vs "-o" "" seems to be the > difference. Is there an explanation? > > Also, some more output with the output with flags -save-temps, -###: > > "/usr/bin/ld" "-m" "i386pep" "--wrap" "_Znwm" "--wrap" "_Znam" "--wrap" > "_ZnwmRKSt9nothrow_t" "--wrap" "_ZnamRKSt9nothrow_t" "--wrap" "_ZdlPv" > "--wrap" "_ZdaPv" "--wrap" "_ZdlPvRKSt9nothrow_t" "--wrap" > "_ZdaPvKSt9nothrow_t" "-Bdynamic" "--tsaware" "-o" "myexecutable" > "/usr/lib/crt0.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtbegin.o" > "-LC:/mylibraries" "-L/usr/lib/gcc/x86_64-pc-cygwin/10" > "-L/usr/x86_64-pc-cygwin/lib" "-L/usr/lib" "-L/usr/lib/w32api" > "my_files\\my_file1.o" "my_files\\my_file2.o" " my_files\\my_file3.o" > "-lnaturedsp" "-lgcc_s" "-gcc" "-lcygwin" "-ladvapi32" "-lshell32" > "-luser32" "-lkernel32" "/usr/lib/default-manifest.o" > "/usr/lib/gcc/x86_64-pc-cygwin/10/crtend.o" > > and with only -###: > > "/usr/bin/ld" "-m" "i386pep" "--wrap" "_Znwm" "--wrap" "_Znam" "--wrap" > "_ZnwmRKSt9nothrow_t" "--wrap" "_ZnamRKSt9nothrow_t" "--wrap" "_ZdlPv" > "--wrap" "_ZdaPv" "--wrap" "_ZdlPvRKSt9nothrow_t" "--wrap" > "_ZdaPvKSt9nothrow_t" "-Bdynamic" "--tsaware" "-o" "myexecutable" > "/usr/lib/crt0.o" "/usr/lib/gcc/x86_64-pc-cygwin/10/crtbegin.o" > "-LC:/mylibraries" "-L/usr/lib/gcc/x86_64-pc-cygwin/10" > "-L/usr/x86_64-pc-cygwin/lib" "-L/usr/lib" "-L/usr/lib/w32api" "" "" "" > "-lnaturedsp" "-lgcc_s" "-lgcc" "-lcygwin" "-ladvapi32" "-lshell32" > "-luser32" "-lkernel32" "/usr/lib/default-manifest.o" > "/usr/lib/gcc/x86_64-pc-cygwin/10/crtend.o" > > So, again "my_files\\my_file1.o" "my_files\\my_file2.o" " > my_files\\my_file3.o" is lost and substituted with empty strings "" "" "" > . > > > Does this info help resolve my problem? > Danijel > > > On Thu, Aug 13, 2020 at 8:27 PM David Blaikie wrote: > >> Oh, sorry, I didn't read the question in detail about how -save-temps >> was making things work when they otherwise were not. >> >> If you run clang with -### it'll show the command lines it's using, >> which should show you where it's trying to write the files so you can >> change that/make them writable. I'm not sure which variable is used to >> influence clang's temporary directory choice, though. >> >> On Thu, Aug 13, 2020 at 11:22 AM Danijel DOMAZET >> wrote: >> > >> > Thanks Fang-rui. >> > I still haven't been able to fix the issue, I still use --save-temps, >> and that makes linking very slow. >> > Why does this error go away when I set --save-temps, any idea?? >> > >> > >> > >> > On Thu, Aug 13, 2020 at 7:16 PM Fāng-ruì Sòng >> wrote: >> >> >> >> On Thu, Aug 13, 2020 at 8:59 AM David Blaikie >> wrote: >> >> > >> >> > On Thu, Aug 13, 2020 at 2:59 AM Danijel DOMAZET >> >> > wrote: >> >> > > >> >> > > Thanks David. >> >> > > Why do you think this could be about