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

llvm-objcopy does not recognize import library #474

Open
romanbtl opened this issue Jan 23, 2025 · 2 comments
Open

llvm-objcopy does not recognize import library #474

romanbtl opened this issue Jan 23, 2025 · 2 comments

Comments

@romanbtl
Copy link

llvm-objcopy does not recognize import library created by llvm-mingw. The attached script works with MinGW but fails with LLVM: x86_64-w64-mingw32-objcopy: error: unsupported object file format

cat << EOF > test.c
__declspec(dllexport) int testfunc(void);

int testfunc(void)
{
  return 42;
}
EOF

x86_64-w64-mingw32-gcc -c test.c -o test.o
x86_64-w64-mingw32-gcc -shared -Wl,--out-implib,test.dll.a test.o -o test.dll
x86_64-w64-mingw32-objcopy test.dll.a test.copy.dll.a

x86_64-w64-mingw32-objcopy: error: unsupported object file format
@mstorsjo
Copy link
Owner

FWIW, it's not directly an issue with the objcopy tool itself, it's about the import library type; GNU tools produce import libraries where each member is a regular object file, while the LLVM tools produce the same kind as MSVC does, with the "short import library" style, where most members are a special kind of file. GNU objcopy also gives an error if doing the same operation on an import library generated by LLVM.

It's probably doable to make this particular trivial case of x86_64-w64-mingw32-objcopy test.dll.a test.copy.dll.a work, but what's the real objcopy operation that you want to do on the libraries, so that if I dig into it, I know what other case needs to work as well. Objcopy can do a dozen of different modifications, which can apply to some cases but not others (e.g. linked executables, or object files, different kinds of object file formats, etc).

@romanbtl
Copy link
Author

I just wanted to try llvm-mingw for our project and came across this. The needed functionality would be --strip-symbol=. But now I see that while it works properly on mingw, the --out-implib adds the __imp_ prefix to all symbols so our project always does a full copy anyway. So I'll start with a dummy wrapper and see what comes next. Thank you for the explanation!

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

No branches or pull requests

2 participants