Skip to content

Instantly share code, notes, and snippets.

@kleisauke
Last active January 11, 2025 15:00
Show Gist options
  • Save kleisauke/38f4a33b77e9f09669c23c8a35f64752 to your computer and use it in GitHub Desktop.
Save kleisauke/38f4a33b77e9f09669c23c8a35f64752 to your computer and use it in GitHub Desktop.
Compat test for the legacy (aka. "long") import library produced by GNU binutils. https://github.com/llvm/llvm-project/commit/5f6d527f091cb20c176817da9b052aa0840de128
FROM docker.io/mstorsjo/llvm-mingw:latest
WORKDIR /build
# Install binutils
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends binutils-mingw-w64 && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p lib/ bin/
# x86-64
RUN echo "__declspec(dllexport) int foo(){return 0;}" | \
x86_64-w64-mingw32-clang -shared -xc -obin/libfoo.dll -Wl,--output-def,lib/libfoo.def -
RUN /usr/bin/x86_64-w64-mingw32-dlltool -m i386:x86-64 -d lib/libfoo.def -l lib/libfoo.dll.a
RUN echo "extern int foo();int main(void){return foo();}" | \
x86_64-w64-mingw32-clang -xc -omain.exe -L/build/lib -lfoo -
# i686
RUN echo "__declspec(dllexport) int foo(){return 0;}" | \
i686-w64-mingw32-clang -shared -xc -obin/libfoo.dll -Wl,--output-def,lib/libfoo.def -
RUN /usr/bin/i686-w64-mingw32-dlltool -m i386 -d lib/libfoo.def -l lib/libfoo.dll.a
RUN echo "extern int foo();int main(void){return foo();}" | \
i686-w64-mingw32-clang -xc -omain.exe -L/build/lib -lfoo -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment