Commit graph

431524 commits

Author SHA1 Message Date
Christoph Heiss 68774ec554
[clang/lib] Add support for Squiid as target OS
Signed-off-by: Christoph Heiss <contact@christoph-heiss.at>
2023-01-28 02:20:47 +01:00
Christoph Heiss 053d967c76
[llvm] Add support for squiid OSType
Signed-off-by: Christoph Heiss <contact@christoph-heiss.at>
2023-01-28 02:19:45 +01:00
Samuel Parker 477e7285b1 [WebAssembly] multivalue stackify fix
Don't attempt to move a multivalue def past one of it's prior uses.

Differential Revision: https://reviews.llvm.org/D137824
2023-01-20 11:20:13 +01:00
Alex Crichton 6c0bab9ef2 Merge remote-tracking branch 'origin/release/15.x' into update-to-llvm-15.0.7 2023-01-13 12:03:21 -08:00
Nikolas Klauser 8dfdcc7b7b [libc++] Fix memory leaks when throwing inside std::vector constructors
Fixes #58392

Reviewed By: ldionne, #libc

Spies: alexfh, hans, joanahalili, dblaikie, libcxx-commits

Differential Revision: https://reviews.llvm.org/D138601
2023-01-11 23:12:30 -08:00
Sylvestre Ledru 939f5a3371 libc++: bring back the unsigned in the return type in wcstoull_l
got remove here:
67b0b02ec9 (diff-e41832b8aa26da45585a57c5111531f2e1d07e91a67c4f8bf1cd6d566ae45a2bR42)

Differential Revision: https://reviews.llvm.org/D141208

(cherry picked from commit fc87452916c0d8759625aad65e9335778ce9cc68)
2023-01-11 23:12:22 -08:00
Josh Stone 948cadd6d4 [RegAllocFast] Handle new debug values for spills
These new debug values get inserted after the place where the spill
happens, which means they won't be reached by the reverse traversal of
basic block instructions. This would crash or fail assertions if they
contained any virtual registers to be replaced. We can manually handle
the new debug values right away to resolve this.

Fixes https://github.com/llvm/llvm-project/issues/59172

Reviewed By: StephenTozer

Differential Revision: https://reviews.llvm.org/D139590

(cherry picked from commit 87f57f459e7acbb00a6ca4ee6dec6014c5a97e07)
2023-01-11 17:16:45 -08:00
Dan Gohman 1095870e8c [wasm-ld] Define a __heap_end symbol marking the end of allocated memory.
Define a `__heap_end` symbol that marks the end of the memory region
that starts at `__heap_base`. This will allow malloc implementations to
know how much memory they can use at `__heap_base` even if someone has
done a `memory.grow` before they can initialize their state.

Differential Revision: https://reviews.llvm.org/D136110
2023-01-10 17:01:48 -08:00
chenglin.bi 67fd0d2af4 [TypePromotion] Add truncate in ConvertTruncs when the original truncate type is not extend type
If the src type is not extend type, after convert the truncate to and we need to truncate the and also to make sure the all user is legal.

The old fix D137613 doesn't work when the truncate convert to and have the other users. So this time I try to add the truncate after and to avoid all these potential issues.

Fix: #59554

Reviewed By: samparker

Differential Revision: https://reviews.llvm.org/D140869

(cherry picked from commit a0b470c9848c638e86f97eca53063642e07cea67)
2023-01-10 12:59:38 -08:00
Bill Wendling 74d3ba1af5 [X86] Don't zero out %eax if both %al and %ah are used
The iterator over super and sub registers doesn't include both 8-bit
registers in its list. So if both registers are used and only one of
them is live on return, then we need to make sure that the other 8-bit
register is also marked as live and not zeroed out.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D139679

(cherry picked from commit 14d4cddc5506fb0fd3c4ac556b4edd970aa151eb)
2023-01-09 12:09:00 -08:00
Tom Stellard a8af9f6792 Bump version to 15.0.7 2023-01-06 13:09:17 -08:00
chenglin.bi 9ad24035fe [TypePromotion] Add truncate in ConvertTruncs when the original truncate type is not extend type
If the src type is not extend type, after convert the truncate to and we need to truncate the and also to make sure the all user is legal.

The old fix D137613 doesn't work when the truncate convert to and have the other users. So this time I try to add the truncate after and to avoid all these potential issues.

Fix: #59554

Reviewed By: samparker

Differential Revision: https://reviews.llvm.org/D140869

(cherry picked from commit a0b470c9848c638e86f97eca53063642e07cea67)
2023-01-03 12:07:54 +01:00
Matthias Braun 3dfd4d93fa ControlHeightReduction: Remove assert check in shouldApply
Remove assertion checking for non-empty `ProfileSummaryInfo`.

Differential Revision: https://reviews.llvm.org/D133706

(cherry picked from commit 6d972ad2d8f1cfe22a61d1c4aed6089f0586b377)
2022-12-07 08:39:47 +01:00
Nikita Popov dc5fa02507 [rust] Fix lld build errors with GCC 5.2 2022-12-07 08:39:47 +01:00
Nikita Popov bebfb21f9a [rust] Fix compile error on GCC 5.4 2022-12-07 08:39:47 +01:00
Nikita Popov 5f1781e4c6 [rust] Fix ICE on GCC 5.4 2022-12-07 08:39:47 +01:00
Nikita Popov aaee1d2723 [rust] Remove constexpr from functions that call non-constexpr functions
The CHECK macros will call non-constexpr functions on failure. While
this is legal C++14 as long as the function doesn't actually get called,
GCC 5.4 will choke on it.
2022-12-07 08:39:47 +01:00
Nikita Popov 783da8c589 [rust] Work around ICE in GCC 5.4 2022-12-07 08:39:47 +01:00
Josh Stone e746ae8048 [rust] Skip processor info on i386 mingw-w64 < 7
This will limit LLVM thread pools to a single thread on that target, but
we don't use that functionality in rustc anyway.

See also:
8404aeb56a (commitcomment-37406150)
2022-12-07 08:39:47 +01:00
Adrian Cruceru 9d74699edc [rust] Changes needed for 'x86_64-fortanix-unknown-sgx' nightly target.
Code is guarded via defines to enable only if 'RUST_SGX' is present.

Main logic is in libunwind/src/AddressSpace.hpp
We use 6 symbols to figure out where eh_frame / eh_frame_hdr is at runtime when loaded in an SGX enclave. (EH symbols + IMAGE base)
These are set by 'fortanix-sgx-tools'.

As notes:
- Target above at the moment uses a pre-compiled libunwind.a from forked repo.
- Goal of these changes is to use official llvm with patch.
- Changes in rust-lang to use this are planned if/when this is accepted.
- Ticket: fortanix/rust-sgx#174
- Original ported changes: llvm/llvm-project@release/5.x...fortanix:release/5.x
2022-12-07 08:39:47 +01:00
Nikita Popov 76b1dfdd09 [rust] Comment out __builtin_available() use (#21)
__builtin_available() pulls in __isOSVersionAtLeast() from
compiler-rt. Comment it out so we don't have to figure out how
to pull in this symbol...
2022-12-07 08:38:19 +01:00
Alex Crichton 405217ea31 [rust] Compile with /MT on MSVC
Can't seem to figure out how to do this without this patch...
2022-12-07 08:38:19 +01:00
Cameron Hart 0a157fd7a5 [rust] Add accessors for MCSubtargetInfo CPU and Feature tables
This is needed for `-C target-cpu=help` and `-C target-feature=help` in rustc
2022-12-07 08:38:19 +01:00
yronglin 088f33605d [CodeGen][ARM] Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg
Fix ARMABIInfo::EmitVAAarg crash with empty record type variadic arg

Open issue: https://github.com/llvm/llvm-project/issues/58794

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D138137

(cherry picked from commit 80f444646c62ccc8b2399d60ac91e62e6e576da6)
2022-11-29 11:05:58 +01:00
Brett Werling abcd0341d8 [ELF] Handle GCC collect2 -plugin-opt= on Windows
Follows up on commit cd5d5ce235 by
additionally ignoring relative paths ending in "lto-wrapper.exe" as
can be the case for GCC cross-compiled for Windows.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D138065

(cherry picked from commit cf4f35b78871aecc21e663067c57e60595bd7197)
2022-11-29 10:26:09 +01:00
Bill Wendling e6e61e9b2e Revert "Reapply: Add an error message to the default SIGPIPE handler"
This patch is spamming compiles with unhelpful and confusing messages.
E.g. the Linux kernel uses "grep -q" in several places. It's meant to
quit with a return code of zero when the first match is found. This can
cause a SIGPIPE signal, but that's expected, and there's no way to turn
this error message off to avoid spurious error messages.

UNIX03 apparently doesn't require printing an error message on SIGPIPE,
but specifically when there's an error on the stdout stream in a normal
program flow, e.g. when SIGPIPE trap is disabled.

A separate patch is planned to address the specific case we care most
about (involving llvm-nm).

This reverts commit b89bcefa62.

Link: https://github.com/llvm/llvm-project/issues/59037
Link: https://github.com/ClangBuiltLinux/linux/issues/1651

Differential Revision: https://reviews.llvm.org/D138244

(cherry picked from commit 4787efa38066adb51e2c049499d25b3610c0877b)
2022-11-23 06:36:25 -08:00
Tom Stellard 25a36ca5c7 Bump version to 15.0.6 2022-11-21 10:38:24 -08:00
Tom Stellard 154e88af7e Bump version to 15.0.5 2022-11-15 22:28:29 -08:00
Florian Hahn a399896637 [VectorUtils] Skip interleave members with diff type and alloca sizes.
Currently, codegen doesn't support cases where the type size doesn't
match the alloc size. Skip them for now.

Fixes #58722.

(cherry picked from commit 758699c39984296f20a4dac44c6892065601c4cd)
2022-11-15 15:45:14 -08:00
serge-sans-paille dc8f6ffc3b [lldb] Get rid of __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
C++11 made the use of these macro obsolete, see https://sourceware.org/bugzilla/show_bug.cgi?id=15366

As a side effect this prevents https://github.com/swig/swig/issues/2193.

Differential Revision: https://reviews.llvm.org/D134877

(cherry picked from commit 81fc5f7909a4ef5a8d4b5da2a10f77f7cb01ba63)
2022-11-15 15:42:01 -08:00
Jitka Plesnikova 392963bb1d [lldb] Fix 'error: non-const lvalue...' caused by SWIG 4.1.0
Fix the failure caused by change in SwigValueWraper for C++11 and later
for improved move semantics in SWIG commit.

d1055f4b3d
(cherry picked from commit f0a25fe0b746f56295d5c02116ba28d2f965c175)
2022-11-15 15:42:01 -08:00
Arthur Eubanks 68799e789f [GlobalOpt] Don't remove inalloca from varargs functions
Varargs and inalloca have a weird interaction where varargs are actually
passed via the inalloca alloca. Removing inalloca breaks the varargs
because they're still not passed as separate arguments.

Fixes #58718

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D137182

(cherry picked from commit 8c49b01a1ee051ab2c09be4cffc83656ccc0fbe6)
2022-11-15 15:40:40 -08:00
Balazs Benics 11c3a21f8d [analyzer] Workaround crash on encountering Class non-type template parameters
The Clang Static Analyzer will crash on this code:
```lang=C++
struct Box {
  int value;
};
template <Box V> int get() {
  return V.value;
}
template int get<Box{-1}>();
```
https://godbolt.org/z/5Yb1sMMMb

The problem is that we don't account for encountering `TemplateParamObjectDecl`s
within the `DeclRefExpr` handler in the `ExprEngine`.

IMO we should create a new memregion for representing such template
param objects, to model their language semantics.
Such as:
 - it should have global static storage
 - for two identical values, their addresses should be identical as well
http://eel.is/c%2B%2Bdraft/temp.param#8

I was thinking of introducing a `TemplateParamObjectRegion` under `DeclRegion`
for this purpose. It could have `TemplateParamObjectDecl` as a field.

The `TemplateParamObjectDecl::getValue()` returns `APValue`, which might
represent multiple levels of structures, unions and other goodies -
making the transformation from `APValue` to `SVal` a bit complicated.

That being said, for now, I think having `Unknowns` for such cases is
definitely an improvement to crashing, hence I'm proposing this patch.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D135763

(cherry picked from commit b062ee7dc4515b0a42157717105839627d5542bb)
2022-11-15 15:37:36 -08:00
Sam James 0988addf26 Link libclangBasic against libatomic when necessary.
This is necessary at least on PPC32.

Depends on D136280.

Bug: https://bugs.gentoo.org/874024
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Differential Revision: https://reviews.llvm.org/D136282

(cherry picked from commit 20132d8eaa68a6c53e152718beda1dc0f4c9ff6c)
2022-11-10 17:04:34 -08:00
Sam James 4c3d83810a Link liblldCOFF against libatomic when necessary
Also simplify code for liblldCommon using the new LLVM_ATOMIC_LIB variable.

Depends on D136280.

Bug: https://bugs.gentoo.org/832675
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Differential Revision: https://reviews.llvm.org/D136281

(cherry picked from commit f0b451c77f14947e3e7d314f048679fa2f5c6298)
2022-11-10 17:04:34 -08:00
Sam James d75ae21044 Set LLVM_ATOMIC_LIB variable for convenient linking against libatomic
* Set LLVM_ATOMIC_LIB to keep track of when we need to link against libatomic.
* Add detection of mold linker which is required for this.
* Use --as-needed when linking against libatomic as a bonus. On some platforms,
  libatomic may be required only sometimes.

Bug: https://bugs.gentoo.org/832675
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Differential Revision: https://reviews.llvm.org/D136280

(cherry picked from commit fa981b541365190ae646d2dce575706cd0626cf7)
2022-11-10 17:04:34 -08:00
chenglin.bi 6750e341b0 [TypePromotion] Replace Zext to Truncate for the case src bitwidth is larger
Fix: https://github.com/llvm/llvm-project/issues/58843

Reviewed By: samtebbs

Differential Revision: https://reviews.llvm.org/D137613

(cherry picked from commit 597f44409236bf7fa933a4ce18af23772e28fb43)
2022-11-10 17:00:50 -08:00
Michał Górny 58ba50a52e [cmake] Add missing CMakePushCheckState include to FindLibEdit.cmake
Add the missing include to fix an error when `cmake_push_check_state()`
is called and incidentally the CMakePushCheckState module is not loaded
by any other check running prior to `FindLibEdit.cmake`:

    CMake Error at /var/no-tmpfs/portage/dev-util/lldb-15.0.4/work/cmake/Modules/FindLibEdit.cmake:24 (cmake_push_check_state):
      Unknown CMake command "cmake_push_check_state".
    Call Stack (most recent call first):
      cmake/modules/LLDBConfig.cmake:52 (find_package)
      cmake/modules/LLDBConfig.cmake:59 (add_optional_dependency)
      CMakeLists.txt:28 (include)

Gentoo Bug: https://bugs.gentoo.org/880065

Differential Revision: https://reviews.llvm.org/D137555

(cherry picked from commit 3676a86a4322e8c2b9c541f057b5d3704146b8f3)
2022-11-10 16:57:19 -08:00
Aaron Ballman 931b6d51d8 Reenable POSIX builtin library functions in gnu2x mode
gnu17 and earlier modes automatically expose several POSIX C APIs, and
this was accidentally disabled for gnu2x in
7d644e1215.

This restores the behavior for gnu2x mode (without changing the
behavior in C standards modes instead of GNU modes).

Fixes #56607
2022-11-10 16:55:23 -08:00
Sam James c8e7a87b1e [CMake] Fix -Wstrict-prototypes
Fixes warnings (or errors, if someone injects -Werror in their build system,
which happens in fact with some folks vendoring LLVM too) with Clang 16:
```
+/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype
is deprecated in all versions of C [-Wstrict-prototypes]
-/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is
deprecated in all versions of C [-Werror,-Wstrict-prototypes]
 int main() {return 0;}
         ^
          void
```

Differential Revision: https://reviews.llvm.org/D137503

(cherry picked from commit 32a2af44e1e882f13d1cc2817f0a8d4d8b375d4d)
2022-11-10 16:53:39 -08:00
Matt Arsenault 5c68a1cb12 AMDGPU: Make various vector undefs legal
Surprisingly these were getting legalized to something
zero initialized.

This fixes an infinite loop when combining some vector types.
Also fixes zero initializing some undef values.

SimplifyDemandedVectorElts / SimplifyDemandedBits are not checking
for the legality of the output undefs they are replacing unused
operations with. This resulted in turning vectors into undefs
that were later re-legalized back into zero vectors.

(cherry picked from commit 7a84624079a2656c684bed6100708544500c5a32)
2022-11-01 20:11:40 -07:00
Yonghong Song 80a9fc840b [clang][Sema] Fix a clang crash with btf_type_tag
For the following program,
  $ cat t.c
  struct t {
   int (__attribute__((btf_type_tag("rcu"))) *f)();
   int a;
  };
  int foo(struct t *arg) {
    return arg->a;
  }
Compiling with 'clang -g -O2 -S t.c' will cause a failure like below:
  clang: /home/yhs/work/llvm-project/clang/lib/Sema/SemaType.cpp:6391: void {anonymous}::DeclaratorLocFiller::VisitParenTypeLoc(clang::ParenTypeLoc):
         Assertion `Chunk.Kind == DeclaratorChunk::Paren' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  ......
  #5 0x00007f89e4280ea5 abort (/lib64/libc.so.6+0x21ea5)
  #6 0x00007f89e4280d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
  #7 0x00007f89e42a6456 (/lib64/libc.so.6+0x47456)
  #8 0x00000000045c2596 GetTypeSourceInfoForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
  #9 0x00000000045ccfa5 GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
  ......

The reason of the failure is due to the mismatch of TypeLoc and D.getTypeObject().Kind. For example,
the TypeLoc is
  BTFTagAttributedType 0x88614e0 'int  btf_type_tag(rcu)()' sugar
  |-ParenType 0x8861480 'int ()' sugar
  | `-FunctionNoProtoType 0x8861450 'int ()' cdecl
  |   `-BuiltinType 0x87fd500 'int'
while corresponding D.getTypeObject().Kind points to DeclaratorChunk::Paren, and
this will cause later assertion.

To fix the issue, similar to AttributedTypeLoc, let us skip BTFTagAttributedTypeLoc in
GetTypeSourceInfoForDeclarator().

Differential Revision: https://reviews.llvm.org/D136807
2022-11-01 17:33:53 -07:00
Koakuma 08bd84e8a6 [SPARC] Make calls to function with big return values work
Implement CanLowerReturn and associated CallingConv changes for SPARC/SPARC64.

In particular, for SPARC64 there's new `RetCC_Sparc64_*` functions that handles the return case of the calling convention.
It uses the same analysis as `CC_Sparc64_*` family of funtions, but fails if the return value doesn't fit into the return registers.

This makes calls to functions with big return values converted to an sret function as expected, instead of crashing LLVM.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D132465

(cherry picked from commit d3fcbee10d893b9e01e563c3840414ba89283484)
2022-10-28 09:38:21 +02:00
Guillaume Chatelet 9d46557baa Take memset_inline into account in analyzeLoadFromClobberingMemInst
This appeared in https://reviews.llvm.org/D126903#3884061

Differential Revision: https://reviews.llvm.org/D136752

(cherry picked from commit 1a726cfa83667585dd87a9955ed5e331cad45d18)
2022-10-28 09:37:34 +02:00
Jez Ng dd711a9391 [lld-macho] Canonicalize personality pointers in EH frames
We already do this for personality pointers referenced from compact
unwind entries; this patch extends that behavior to personalities
referenced via EH frames as well.

This reduces the number of distinct personalities we need in the final
binary, and helps us avoid hitting the "too many personalities" error.

I renamed `UnwindInfoSection::prepareRelocations()` to simply `prepare`
since we now do some non-reloc-specific stuff within.

Fixes #58277.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D135728

(cherry picked from commit 7b45dfc6811a52ff4e9a6054dc276d70d77fddaf)
2022-10-28 09:37:27 +02:00
Timm Bäder 3010b7e000 [clang][driver] Remove dynamic gcc-toolset/devtoolset logic
This breaks when the newest available devtoolset directory is not a
complete toolset: https://github.com/llvm/llvm-project/issues/57843

Remove this again in favor or just adding the two new directories for
devtoolset/gcc-toolset 12.

This reverts commit 35aaf54823.
This reverts commit 9f97720268.

Fixes https://github.com/llvm/llvm-project/issues/57843

Differential Revision: https://reviews.llvm.org/D136435
2022-10-27 22:01:32 -07:00
Tom Praschan db68723804 [clangd] Return earlier when snippet is empty
Fixes github.com/clangd/clangd/issues/1216

If the Snippet string is empty, Snippet.front() would trigger a crash.
Move the Snippet->empty() check up a few lines to avoid this. Should not
break any existing behavior.

Differential Revision: https://reviews.llvm.org/D134137

(cherry picked from commit 60528c690a4c334d2a3a2c22eb97af9e67d7a91d)
2022-10-25 09:37:35 +02:00
Jonas Devlieghere 2d5c43ad48 [lldb] Automatically unwrap parameter packs in template argument accessors
When looking at template arguments in LLDB, we usually care about what
the user passed in his code, not whether some of those arguments where
passed as a variadic parameter pack.

This patch extends all the C++ APIs to look at template parameters to
take an additional 'expand_pack' boolean that automatically unwraps the
potential argument packs. The equivalent SBAPI calls have been changed
to pass true for this parameter.

A byproduct of the patch is to also fix the support for template type
that have only a parameter pack as argument (like the OnlyPack type in
the test). Those were not recognized as template instanciations before.

The added test verifies that the SBAPI is able to iterate over the
arguments of a variadic template.

The original patch was written by Fred Riss almost 4 years ago.

Differential revision: https://reviews.llvm.org/D51387

(cherry picked from commit b706f56133a77f9d7c55270ac24ff59e6fce3fa4)
2022-10-25 09:37:29 +02:00
Tom Stellard 1e1c5204c2 [SystemZ] Relase notes for LLVM 15
Unfortunately these notes were compiled until now, but these are the release notes for SystemZ.

(Did not find anything under clang)

@tstellar Should I push this patch onto release/15.x once approved, or will you apply it?

Differential Revision: https://reviews.llvm.org/D134430
2022-10-24 14:48:32 -07:00
Fangrui Song dccd061302 [ELF] Suppress "duplicate symbol" when resolving STB_WEAK and STB_GNU_UNIQUE in different COMDATs
```
template <typename T> struct A {
  A() {}
  int value = 0;
};

template <typename Value> struct B {
  static A<int> a;
};

template <typename Value> A<int> B<Value>::a;

inline int foo() {
  return B<int>::a.value;
}
```

```
clang++ -c -fno-pic a.cc -o weak.o
g++ -c -fno-pic a.cc -o unique.o  # --enable-gnu-unique-object

# Duplicate symbol error. In postParse, we do not check `sym.binding`
ld.lld -e 0 weak.o unique.o
```

Mixing GCC and Clang object files in this case is not ideal. .bss._ZGVN1BIiE1aE
has different COMDAT groups. It appears to work in practice because the guard
variable prevents harm due to double initialization.

For the linker, we just stick with the rule that a weak binding does not cause
"duplicate symbol" errors.

Close https://github.com/llvm/llvm-project/issues/58232

Differential Revision: https://reviews.llvm.org/D136381

(cherry picked from commit 0051b6bb78772b0658f28e5f31ddf91c1589aab5)
2022-10-24 13:49:35 +02:00