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

output static lib is being deleted after compilation #18578

Closed
veksha opened this issue Jul 25, 2021 · 0 comments · Fixed by #18580 or sthagen/nim-lang-Nim#242
Closed

output static lib is being deleted after compilation #18578

veksha opened this issue Jul 25, 2021 · 0 comments · Fixed by #18580 or sthagen/nim-lang-Nim#242

Comments

@veksha
Copy link

veksha commented Jul 25, 2021

Example

compile your nim file (even empty) using nim c --app:staticLib sometest.nim

Current Output

File sometest.lib gets created and then deleted instantly.

Hint: used config file 'D:\Programm\Nim\Nim-devel\config\nim.cfg' [Conf]
Hint: used config file 'D:\Programm\Nim\Nim-devel\config\config.nims' [Conf]
Hint: used config file 'D:\Programm\Nim\nimwrap\sometest.nim.cfg' [Conf]
........................................................
CC: sometest.nim
Hint:  [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
26617 lines; 1.724s; 31.941MiB peakmem; proj: D:\Programm\Nim\nimwrap\sometest.nim; out: D:\Programm\Nim\nimwrap\sometest.lib [SuccessX]

Expected Output

file sometest.lib being created and stays put.

Possible Solution

Additional Information

git bisect shows this commit as first bad:
ba64d0c

--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -662,6 +662,7 @@ proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) =
 proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile,
                 objfiles: string, isDllBuild: bool): string =
   if optGenStaticLib in conf.globalOptions:
+    removeFile output # fixes: bug #16947
     result = CC[conf.cCompiler].buildLib % ["libfile", quoteShell(output),
                                             "objfiles", objfiles]
   else:

But i personally see nothing wrong about it. the output file gets deleted before the call to buildLib.
this is very strange. please help.

$ nim -v
Nim Compiler Version 1.5.1 [Windows: amd64]
Compiled at 2021-07-25
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f4ff276a90091f2b88c191aac5a201dcb3ec9795
active boot switches:
gcc and ld version
gcc -v
Using built-in specs.
COLLECT_GCC=D:\Programm\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=d:/programm/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-10.2.0/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-multilib --enable-64bit --disable-dependency-tracking --prefix=/mingw64 --with-sysroot=/mingw64 --disable-shared --enable-static --disable-nls --enable-version-specific-runtime-libs --disable-win32-registry --without-dwarf2 --enable-sjlj-exceptions --enable-fully-dynamic-string --enable-languages=c,d,ada,lto,c++,objc,obj-c++,fortran --enable-libgomp --enable-lto --enable-libssp -enable-gnattools --disable-bootstrap --with-gcc --with-gnu-as --with-gnu-ld --with-stabs --enable-interwork --with-mpfr-include=/home/betta/gcc-build/../gcc-10.2.0/mpfr/src --with-mpfr-lib=/home/betta/gcc-build/mpfr/src/.libs --enable-objc-gc --with-target-bdw-gc=/mingw64
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
ld -v
GNU ld (GNU Binutils) 2.35.1
ringabout added a commit to ringabout/Nim that referenced this issue Jul 25, 2021
@ringabout ringabout mentioned this issue Jul 25, 2021
Araq pushed a commit that referenced this issue Jul 27, 2021
* fix #18578

* add tests

* tiny

* apply changes

* typo

* add removeStaticFile
sthagen added a commit to sthagen/nim-lang-Nim that referenced this issue Jul 27, 2021
PMunch pushed a commit to PMunch/Nim that referenced this issue Mar 28, 2022
* fix nim-lang#18578

* add tests

* tiny

* apply changes

* typo

* add removeStaticFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants