[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
@@ -977,14 +977,61 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, return true; } -void tools::addFortranRuntimeLibs(const ToolChain &TC, +void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
@@ -977,14 +977,61 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, return true; } -void tools::addFortranRuntimeLibs(const ToolChain &TC, +void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From 2a2693364cb8e9b657b9ff54aa78df0466b55fe4 Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/14] Let the linker fail on multiple definitions of main() ---

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
@@ -977,14 +977,63 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, return true; } -void tools::addFortranRuntimeLibs(const ToolChain &TC, +void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From 2a2693364cb8e9b657b9ff54aa78df0466b55fe4 Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/14] Let the linker fail on multiple definitions of main() ---

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
mjklemm wrote: Folks, I have made another attempt to improve this patch. @kparzysz with your feedback in mind, I have now added a check if `--whole-archive` is active for some reason. If so, flang will not add it to the link line again. https://github.com/llvm/llvm-project/pull/73124 ___

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From 2a2693364cb8e9b657b9ff54aa78df0466b55fe4 Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/13] Let the linker fail on multiple definitions of main() ---

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
@@ -977,14 +977,51 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, return true; } -void tools::addFortranRuntimeLibs(const ToolChain &TC, +void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm edited https://github.com/llvm/llvm-project/pull/73124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
@@ -977,14 +977,51 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, return true; } -void tools::addFortranRuntimeLibs(const ToolChain &TC, +void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
mjklemm wrote: > I think so yes. The issue is that Windows really wants these things to be in > the object files rather than passed on the link line, which is what the patch > you're referencing changed for linking the runtimes at least. Doing that for > this as well is a little more complex t

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From 2a2693364cb8e9b657b9ff54aa78df0466b55fe4 Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/12] Let the linker fail on multiple definitions of main() ---

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
mjklemm wrote: > I think for Windows the easy thing to do here is just to add > `/WHOLEARCHIVE:...` here anyway, using the same logic as in > processVSRuntimeLibrary(); E.g > > ``` > void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, > //need to add args here so we ca

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
mjklemm wrote: FYI: Rebased and resolved conflict flagged by GitHub. Alas, this means that I have lost the change to also make the linker fail on Windows. I've sent a request to the authors of the code to perform linking on Windows to help me figure out what to do. https://github.com/llvm/l

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From 2a2693364cb8e9b657b9ff54aa78df0466b55fe4 Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/11] Let the linker fail on multiple definitions of main() ---

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-25 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From ba38aec7ac04c63fd5167908fe7f91d6ac7bceed Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 01/11] Let the linker fail on multiple definitions of main() ---

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,15 @@ +! UNSUPPORTED: system-windows + +! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/main_dupes.ll +! RUN: %flang -o %t -c %s +! RUN: not %flang -o %t.exe %t %t.c-object 2>&1 mjklemm wrote: I'd actually prefer to have a separate test for this, as a

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
mjklemm wrote: > LGTM, thank you for taking care of this 🙏🏻 > > Dare I ask - what's "dupes"? I only found > [dupe](https://dictionary.cambridge.org/dictionary/english/dupe). Also, > please wait for @kiranchandramohan to approve before merging this :) I used "dupes" in the sense of being foole

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,15 @@ +! UNSUPPORTED: system-windows + +! RUN: %clang -o %t.c-object -c %S/Inputs/main_dupes.c mjklemm wrote: This change is also gone now and has been removed. https://github.com/llvm/llvm-project/pull/73124 __

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,8 @@ +#include + +int main(int argc, char * argv[]) { +// Irrelevant what to do in here. +// Test is supposed to fail at link time. +printf("Hello from C [%s]\n", __FUNCTION__); mjklemm wrote: This is also gone with the move to an LL file.

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
@@ -122,6 +122,7 @@ # the build directory holding that tool. tools = [ ToolSubst("%flang", command=FindTool("flang-new"), unresolved="fatal"), +ToolSubst("%clang", command=FindTool("clang"), unresolved="fatal"), mjklemm wrote: I have removed this in fa

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From ba38aec7ac04c63fd5167908fe7f91d6ac7bceed Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 1/9] Let the linker fail on multiple definitions of main() --- c

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-24 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,13 @@ +! RUN: %clang -x c -o %t.c-part -c %s.c-part mjklemm wrote: That has worked. I haven't thought about that at all, so many thanks for the suggestion. This greatly simplifies things! https://github.com/llvm/llvm-project/pull/73124

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,15 @@ +! UNSUPPORTED: system-windows + +! RUN: %clang -o %t.c-object -c %S/Inputs/main_dupes.c mjklemm wrote: When I do this, the test goes to "unsupported" for me, as it seems that %cc is not set as a substitution in lit.cfg.py. https://github.com/l

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
mjklemm wrote: Done. https://github.com/llvm/llvm-project/pull/73124 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From ba38aec7ac04c63fd5167908fe7f91d6ac7bceed Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 1/6] Let the linker fail on multiple definitions of main() --- c

[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
@@ -0,0 +1,13 @@ +! RUN: %clang -x c -o %t.c-part -c %s.c-part mjklemm wrote: That does not seem to work and gives me this error when running the test. `error: unknown integrated tool '-cc1'. Valid tools include '-fc1'.` I do not necessarily need `clang` as the

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
mjklemm wrote: > Would it be possible to test this? I have added a simple test. It checks that the linker indeed fails, but does not check the actual linker error message. PLease let me know if that's desired. I could then provide the error messages for LD and LLD. For other environments,

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
@@ -122,6 +122,7 @@ # the build directory holding that tool. tools = [ ToolSubst("%flang", command=FindTool("flang-new"), unresolved="fatal"), +ToolSubst("%clang", command=FindTool("clang"), unresolved="fatal"), mjklemm wrote: @banach-space I had to ad

[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-23 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From ba38aec7ac04c63fd5167908fe7f91d6ac7bceed Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 1/5] Let the linker fail on multiple definitions of main() --- c

[clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-22 Thread Michael Klemm via cfe-commits
mjklemm wrote: > Would it be possible to test this? Sure thing! That's the next thing I can look at. I'd like to probe though if the general solution is acceptable. https://github.com/llvm/llvm-project/pull/73124 ___ cfe-commits mailing list cfe-co

[clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-22 Thread Michael Klemm via cfe-commits
@@ -1029,7 +1042,7 @@ void tools::addFortranRuntimeLibraryPath(const ToolChain &TC, ArgStringList &CmdArgs) { // Default to the /../lib directory. This works fine on the // platforms that we have tested so far. We will probably have

[clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-22 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/73124 >From ba38aec7ac04c63fd5167908fe7f91d6ac7bceed Mon Sep 17 00:00:00 2001 From: Michael Klemm Date: Wed, 22 Nov 2023 14:22:20 +0100 Subject: [PATCH 1/2] Let the linker fail on multiple definitions of main() --- c

[clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-22 Thread Michael Klemm via cfe-commits
https://github.com/mjklemm created https://github.com/llvm/llvm-project/pull/73124 The flang driver was silently ignoring the `main()` function in `Fortran_main.a` for entry into the Fortran program unit if an external `main()` as supplied (e.g., via cross-language linkage with Fortran and C/C

<    1   2