llvm-mingw icon indicating copy to clipboard operation
llvm-mingw copied to clipboard

Regression: llvm-mingw-20240502-msvcrt i686: duplicate symbol '_time'

Open markus-oberhumer opened this issue 1 year ago • 4 comments

Hi,

our CI job has found a possible regression in the latest 20240502 update.

This is triggered by llvm-mingw-20240502-msvcrt-ubuntu-20.04-x86_64/bin/i686-w64-mingw32-clang++ and seems to indicate a problem with duplicate symbols of _time and friends.

CI log failure llvm-mingw-20240502: https://github.com/upx/upx-test-threads/actions/runs/8995428127/job/24710366347

FYI, CI log last success llvm-mingw-20240417: https://github.com/upx/upx-test-threads/actions/runs/8904612956

P.S. many thanks for providing these builds!

markus-oberhumer avatar May 03 '24 10:05 markus-oberhumer

Thanks for the report! I presume this is caused by https://github.com/mingw-w64/mingw-w64/commit/1652e9241b5d8a5a779c6582b1c3c4f4a7cc66e5.

A later patch that is part of a larger patch set, that still is in progress, should fix this. I’ll let you know when a fix is available.

mstorsjo avatar May 03 '24 13:05 mstorsjo

@markus-oberhumer Headsup - when testing a fix for this issue, I noticed another recent regression on the main branch of Clang; you should be able to try it out with https://github.com/mstorsjo/llvm-mingw/releases/nightly. (I don't provide nightly builds targeting msvcrt, but this regression is unrelated to the CRT choice.)

https://github.com/llvm/llvm-project/commit/29d447a6e446e7fd78bd28af28bbf7dd377ade10 and https://github.com/llvm/llvm-project/pull/90676 changed so that each time <stddef.h> is included, it applies its contents. This seems to be somewhat intentional.

In upx, in compress_lzma.cpp, at https://github.com/upx/upx/blob/devel/src/compress/compress_lzma.cpp#L209-L218, there seems to be attempts to redefine NULL to nullptr. However, when including other later files, many of them (re)include <stddef.h>, which now will end up redefining NULL back to 0. This causes errors like these:

/home/martin/code/upx/vendor/lzma-sdk/C/7zip/Compress/LZMA/../../../Common/MyCom.h:84:26: error: zero as null pointer constant [-Werror,-Wzero-as-null-pointer-constant]                                             
   84 |   CMyComBSTR() { m_str = NULL; }
      |                          ^~~~                                   
      |                          nullptr
/home/martin/clang-nightly/lib/clang/19/include/__stddef_null.h:23:14: note:
 expanded from macro 'NULL'
   23 | #define NULL 0
      |              ^

mstorsjo avatar May 08 '24 12:05 mstorsjo

@mstorsjo Thanks for that info!

As you have noticed this code is problematic for some other toolchains as well (I have never looked in detail why NULL gets redefined under certain circumstances), so I've now opted for the easy solution:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"

markus-oberhumer avatar May 08 '24 21:05 markus-oberhumer

This issue should hopefully have been fixed in the latest release, at https://github.com/mstorsjo/llvm-mingw/releases/tag/20240518.

mstorsjo avatar May 20 '24 06:05 mstorsjo

Fixed in 20240518, many thanks!

markus-oberhumer avatar May 21 '24 17:05 markus-oberhumer