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

binutils 2.36 breaks ar when running from command prompt #7890

Closed
xim opened this issue Feb 4, 2021 · 15 comments · Fixed by #8248
Closed

binutils 2.36 breaks ar when running from command prompt #7890

xim opened this issue Feb 4, 2021 · 15 comments · Fixed by #8248

Comments

@xim
Copy link

xim commented Feb 4, 2021

Just upgraded binutils. All uses of ar result in this message when running from command prompt:

c:\msys64\mingw64\lib\bfd-plugins\libdep.a is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc000012f.

Minimal reproduction:

# From msys or git bash
touch empty.c
gcc -c -o empty.o empty.c
ar -rc libempty.a empty.o # Great success!
# Then from command prompt in the same folder
ar -rc libempty.a empty.o

Running the command from a git bash / msys 2prompt works. Running it from a cmd window gives the message. Running it in msys2 invoking cmd /c 'ar -rc [...]' works fine, and surprisingly also when invoking \msys64\usr\bin\bash -c "ar -rc [...]" from the command prompt

Downgrading to binutils 2.35.1-3 resolves the issue. Both 2.36-1 and 2.36-3 exhibit this behaviour.

@Biswa96
Copy link
Member

Biswa96 commented Feb 5, 2021

What is your current working directory aka. $PWD? How do you able to access ar from cmd? Did you add anything to $PATH or %PATH%?

@xim
Copy link
Author

xim commented Feb 5, 2021

It happens in any folder I run it (%TEMP%, C:\Users\xim\Desktop...) and regardless of whether or not I have ar in my PATH or execute it using full path.

I moved ar.exe to ar_.exe and made this horrible .bat file that I placed as \msys64\mingw64\bin\ar.bat to work around:

@set dirname=%~dp0
@set dirname=%dirname:\=/%
@set args=%*
@set args=%args:\=/%
@%dirname%..\..\usr\bin\bash -c "exec %dirname%ar_ %args%"
@if errorlevel 1 exit 1

@xim
Copy link
Author

xim commented Feb 5, 2021

Actually, just removing the bfd-plugins folder also works. Don't know if I'm missing out on anything important when I remove it, though?
Edit: Apparently, I don't use libdep

@lazka
Copy link
Member

lazka commented Feb 5, 2021

I can't reproduce, this works

set PATH=C:/msys64/mingw64/bin;%PATH
ar -rc libempty.a empty.o

@oltolm
Copy link
Contributor

oltolm commented Feb 6, 2021

Can confirm.

@Astrum-polaris
Copy link
Contributor

libdep is a new plugin that is only present in binutils 2.36 (not exists in binutils 2.35)

Actually, just removing the bfd-plugins folder also works. Don't know if I'm missing out on anything important when I remove it, though?

bfd-plugins folder also contains the lto plugin, so removing the entire folder may break lto

I can confirm removing /mingw64/lib/bfd-plugins/libdep.a solves this problem

If I remove --disable-shared in binutils PKGBUILD and rebuild, libdep.dll and libdep.dll.a are installed instead of libdep.a

I guess if you try to run ar in command prompt, files in /mingw64/lib/bfd-plugins are loaded as dll, so if something that is not dll presents in that directory, it will fail with a error message like you posted.

@xim
Copy link
Author

xim commented Feb 6, 2021

bfd-plugins folder also contains the lto plugin, so removing the entire folder may break lto

Good that you pointed that out for those that use lto =)

We have a decent workaround, then, as it isn't likely that many use libdep yet.

@revelator
Copy link
Contributor

hmm cant reproduce either though after the upgrade i now get a lot of warnings about dllwrap being deprecated especially when building python packages.

@PBfordev
Copy link

PBfordev commented Feb 8, 2021

I confirm the issue.

@xim
Copy link
Author

xim commented Feb 8, 2021

I don't have a bunch of Windows machines lying around, but the one I do have is a Windows 10 virtual machine with Windows 10 Enterprise version 20H2 build 19042.746. It's a fairly minimal install, and has the very latest MSYS64 updates. I can provide additional details as requested.

@zufuliu
Copy link

zufuliu commented Feb 9, 2021

libdep.a is still in lib\bfd-plugins folder for mingw-w64-x86_64-binutils-2.36.1-1.
Reproduce the Windows error message dialog (in command prompt, Win10 20H2 19042.746):

git clone --depth=1 https://github.com/zufuliu/notepad2.git
cd build\mingw
mingw32-make -j4

@lazka
Copy link
Member

lazka commented Mar 31, 2021

Removed that plugin now. Sorry for the delay.

mingwandroid pushed a commit to mingwandroid/MINGW-packages that referenced this issue Apr 8, 2021
Not sure if this needs to be fixed or just isn't useful on Windows.

Fixes msys2#7890
danyeaw pushed a commit to danyeaw/MINGW-packages that referenced this issue Apr 9, 2021
Not sure if this needs to be fixed or just isn't useful on Windows.

Fixes msys2#7890
@abrodkin
Copy link

abrodkin commented May 5, 2021

FWIW that's an entry in Bintuils' bug-tracker - https://sourceware.org/bugzilla/show_bug.cgi?id=27113.

@abrodkin
Copy link

And here you are - upstream fix (to be a part of the next 2.37 release): https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22604fe675b25b3ffca56e44f2c0ff378e5c6104.

@lazka
Copy link
Member

lazka commented May 11, 2021

Thanks

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

Successfully merging a pull request may close this issue.

9 participants