flang
                                
                                 flang copied to clipboard
                                
                                    flang copied to clipboard
                            
                            
                            
                        windows static-flang-libs DEFAULTLIB use basename
When using "-static-flang-libs" on windows, the resulting object files declare a "/DEFAULTLIB" against the absolute path of flang.lib (and other static flang libraries). Is there a way to only include the library basename ?
My use-case: I build a static library with flang, and I then would like to be able to link it in a larger binary (no other fortran code). The two steps are done on different machines. Ideally, the second step would be as simple as copying the static library (and the static flang libraries) and finally configuring the linker search path.
The absolute path in DEFAULTLIB makes it harder, as the flang libraries have to be put at the same exact place on both machines.
Can you answer @xoviat @kaadam ?
Part of the code that sets these directives is under #1020. The other part is under the driver that's used on windows here: https://github.com/xoviat/flang/blob/windows/tools/driver/Upper.cpp#L1209. Basically, we add the linker directives to the LLVM IR file, which LLVM lowers to the object file. I seem to remember that it's not possible to embed the LIBPATH directive in an object file, but I could be wrong. I'm I'm wrong, then the solution might be to embed the /DEFAULTLIB and /LIBPATH directives in the object file.
However, this approach would modify the global lib search path for all libraries, not just the flang ones, so perhaps that's not such a good idea. Another option would be to add a new compiler flag that puts only the basename into the object file.
@cassiersg thoughts?
Generally though, the approach that I take is that redistributed libraries should not be static; they should be dynamic. In that case, I don't think this problem occurs.
An option for this would be good. Another solution would be to not include the absolute path when the directory is in LIB or LIBPATH, but maybe that would be to "magical".
I don't know if it is possible to embed LIBPATH in object files.
Re-redistributing static libraries, I don't have a strong opinion in a general "redistibuting" setting. However, there are some cases where this can be useful (e.g. I'm building a statically-linked binary, but I'm pre-compiling a static library since compiling that library is quite slow on CI/developers machines.)