mstorsjo/llvm-mingw

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

markus-oberhumer opened this issue · 5 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!

Thanks for the report! I presume this is caused by mingw-w64/mingw-w64@1652e92.

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.

@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.)

llvm/llvm-project@29d447a and llvm/llvm-project#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 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"

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

Fixed in 20240518, many thanks!