Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

83 lines
2.7 KiB
Plaintext

RUN: lld-link -lldmingw %S/Inputs/inline-weak.o %S/Inputs/inline-weak2.o -out:%t.exe
When compiling certain forms of templated inline functions, some
versions of GCC (tested with 5.4) produces a weak symbol for the function.
Newer versions of GCC don't do this though.
The bundled object files are an example of that, they can be produced
with test code like this:
$ cat inline-weak.h
class MyClass {
public:
template<typename... _Args> int get(_Args&&... args) {
return a;
}
private:
int a;
};
$ cat inline-weak.cpp
#include "inline-weak.h"
int get(MyClass& a);
int main(int argc, char* argv[]) {
MyClass a;
int ret = a.get();
ret += get(a);
return ret;
}
extern "C" void mainCRTStartup(void) {
main(0, (char**)0);
}
extern "C" void __main(void) {
}
$ cat inline-weak2.cpp
#include "inline-weak.h"
int get(MyClass& a) {
return a.get();
}
$ x86_64-w64-mingw32-g++ -std=c++11 -c inline-weak.cpp
$ x86_64-w64-mingw32-g++ -std=c++11 -c inline-weak2.cpp
$ x86_64-w64-mingw32-nm inline-weak.o | grep MyClass3get
0000000000000000 p .pdata$_ZN7MyClass3getIJEEEiDpOT_
0000000000000000 t .text$_ZN7MyClass3getIJEEEiDpOT_
0000000000000000 T .weak._ZN7MyClass3getIIEEEiDpOT_.main
0000000000000000 r .xdata$_ZN7MyClass3getIJEEEiDpOT_
w _ZN7MyClass3getIIEEEiDpOT_
0000000000000000 T _ZN7MyClass3getIJEEEiDpOT_
$ x86_64-w64-mingw32-nm inline-weak2.o | grep MyClass3get
0000000000000000 p .pdata$_ZN7MyClass3getIJEEEiDpOT_
0000000000000000 t .text$_ZN7MyClass3getIJEEEiDpOT_
0000000000000000 T .weak._ZN7MyClass3getIIEEEiDpOT_._Z3getR7MyClass
0000000000000000 r .xdata$_ZN7MyClass3getIJEEEiDpOT_
w _ZN7MyClass3getIIEEEiDpOT_
0000000000000000 T _ZN7MyClass3getIJEEEiDpOT_
This can't be reproduced by assembling .s files with llvm-mc, since that
always produces a symbol named .weak.<weaksymbol>.default, therefore
the test uses prebuilt object files instead.
In these cases, the undefined weak symbol points to the regular symbol
.weak._ZN7MyClass3getIIEEEiDpOT_.<othersymbol>, where <othersymbol>
varies among the object files that emit the same function. This regular
symbol points to the same location as the comdat function
_ZN7MyClass3getIJEEEiDpOT_.
When linking, the comdat section from the second object file gets
discarded, as it matches the one that already exists. This means that
the uniquely named symbol .weak.<weakname>.<othername> points to a
discarded section chunk.
Previously, this would have triggered adding an Undefined symbol for
this case, which would later break linking. However, also previously,
if the second object file is linked in via a static library, this
leftover symbol is retained as a Lazy symbol, which would make the link
succeed.