[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits

https://github.com/rorth closed https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space approved this pull request.

LGTM, thanks for all the improvements!

Before merging, could you update the summary and briefly mention the additional 
changes made here? Otherwise people might think that these changes are 
required, but that's not strictly the case.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/65644

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH 1/3] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

>From bf1b865045ed4f484f24746aa18405d93e760979 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 17 Oct 2023 20:43:23 +0200
Subject: [PATCH 2/3] Rename `GNU` label to `UNIX` to better match use.

---
 flang/test/Driver/linker-flags.f90 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 717dcc7775e2126..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,9 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -22,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

>From 5e7ca991bd8b87b754e982d9836460dc0f31e59f Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Wed, 18 Oct 2023 12:01:15 +0200
Subject: [PATCH 3/3] Use `--target=`.  Join `-l` lines for `UNIX` case.

---
 flang/test/Driver/linker-flags.f90 | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 

[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -21,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main

rorth wrote:

Right: they fit nicely even with the double quotes.  To avoid swamping the 
patch with unrelated changes, I've only adjusted the `UNIX` case.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -2,8 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX

rorth wrote:

Done: since I'd already touched almost half the instances, I changed them all 
for consistency.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-17 Thread Fangrui Song via cfe-commits


@@ -2,8 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX

MaskRay wrote:

while changing the lines, change deprecated `-target ` to `--target=`

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-17 Thread Fangrui Song via cfe-commits


@@ -21,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main

MaskRay wrote:

Personally I prefer testing `-lx -ly -lz` on one line to assert that is no 
extra argument in between.
This line isn't very long.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Rainer Orth (rorth)


Changes

I noticed that `flang-new` cannot link Fortran executables on Solaris since the 
runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase is 
augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

---
Full diff: https://github.com/llvm/llvm-project/pull/65644.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Solaris.cpp (+8) 
- (modified) flang/test/Driver/linker-flags.f90 (+8-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,8 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -21,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

``




https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-17 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/65644

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH 1/2] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

>From bf1b865045ed4f484f24746aa18405d93e760979 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 17 Oct 2023 20:43:23 +0200
Subject: [PATCH 2/2] Rename `GNU` label to `UNIX` to better match use.

---
 flang/test/Driver/linker-flags.f90 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 717dcc7775e2126..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,9 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -22,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-16 Thread Brad Smith via cfe-commits

brad0 wrote:

> * renaming the current label from `GNU` to e.g. `UNIX` would be correct.

That would be fine with me.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-16 Thread Rainer Orth via cfe-commits

rorth wrote:

> I feel that we are bike-shedding here a bit. Please prioritise correctness - 
> using `GNU` as a label for Solaris would not be correct. The following would 
> be:
> 
> * duplicating tests with a different label (e.g. `SOLARIS`) would be 
> correct,
> 
> * renaming the current label from `GNU` to e.g. `UNIX` would be correct.
> 
> 
> Unless I am missing something?

I'd go for renaming the label to `UNIX` then: it avoids unnecessary duplication 
and better describes what those cases are about.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-16 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

> > Agreed: AFAICS the only open issue is whether the Solaris test should use 
> > the `GNU` label as I have done, introduce an new common one (like `UNIX`; 
> > there's nothing GNU-specific in that test), or really introduce a separate 
> > copy of the check under a different label per target (my least preference 
> > because it makes the test hard to read for no gain).
> 
> I think having additional tests makes sense if there is some variation on 
> what is being checked but not when it's just copying and pasting the same 
> thing with a different label.

I feel that we are bike-shedding here a bit. Please prioritise correctness - 
using `GNU` as a label for Solaris would not be correct. The following would be:
* duplicating tests with a different label (e.g. `SOLARIS`) would be correct,
* renaming the current label from `GNU` to e.g. `UNIX` would be correct.

Unless I am missing something?

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-12 Thread Brad Smith via cfe-commits

brad0 wrote:

> Agreed: AFAICS the only open issue is whether the Solaris test should use the 
> `GNU` label as I have done, introduce an new common one (like `UNIX`; there's 
> nothing GNU-specific in that test), or really introduce a separate copy of 
> the check under a different label per target (my least preference because it 
> makes the test hard to read for no gain).

I think having additional tests makes sense if there is some variation on what 
is being checked but not when it's just copying and pasting the same thing with 
a different label.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-11 Thread Rainer Orth via cfe-commits

rorth wrote:

> I'd like for this to move forward.

Agreed: AFAICS the only open issue is whether the Solaris test should use the 
`GNU` label as I have done, introduce an new common one (like `UNIX`; there's 
nothing GNU-specific in that test), or really introduce a separate copy of the 
check under a different label per target (my least preference because it makes 
the test hard to read for no gain).

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-11 Thread Rainer Orth via cfe-commits

rorth wrote:

> > I wonder how to proceed with the patch at hand.
> 
> I'm not a Solaris expert, but based on this discussion I'd consider adding 
> support for `-fuse-ld` in Flang. This sort of changes are often as simple as 
> updating Options.td. Same for `-r`.

Support of `-fuse-ld` is not Solaris-specific in any way.  Other targets 
support e.g. `-fuse-ld=[bfd|lld]`.  That would be just another case of Flang 
needing to support common flags.  However, I don't understand how Flang option 
handling is done, unfortunately.  Whatever the case, this is an issue separate 
from this patch: the only reason we were talking about `-r` and friends is that 
my patch guards adding the Flang runtime libs with `! -nostdlib && ! 
-nodefaultlibs && ! -r`, which I believe we have now established is correct.

However, Flang accepts none of those options yet, which it should for 
compatiblity with both `clang++` and `gfortran`.  However, I won't be able to 
deal with any of this: I've quite a number of other issues on my plate.

> One important rule of thumb that I'd stick to:
> 
> * Do whatever Clang, GFortran and GCC do.
> 
> 
> In cases where there's different behavior between these compilers, just go 
> for whatever feels most sensible, but please document your design decision.

Fully agreed: I've now checked that gfortran handles all of `-r`, `-nostdlib`, 
and `-nodefaultlibs`, so I believe `flang-new` should follow suite.


https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-05 Thread Brad Smith via cfe-commits

brad0 wrote:

I'd like for this to move forward.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-24 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

> I wonder how to proceed with the patch at hand.

I'm not a Solaris expert, but based on this discussion I'd consider adding 
support for `-fuse-ld` in Flang. This sort of changes are often as simple as 
updating Options.td. Same for `-r`.

One important rule of thumb that I'd stick to:
* Do whatever Clang, GFortran and GCC do.

In cases where there's different behavior between these compilers, just go for 
whatever feels most sensible, but please document your design decision.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-22 Thread Rainer Orth via cfe-commits

rorth wrote:

The different behaviour can easily be seen since Solaris `clang` supports 
linker selection at compile time:
```
$ clang -r -o hello-r.o hello.o -fuse-ld=gld
/usr/gnu/bin/ld: warning: cannot find entry symbol _start; not setting start 
address
$ clang -r -o hello-r.o hello.o
ld: fatal: option '-Bdynamic' is incompatible with building a relocatable object
ld: fatal: option '-e _start' is incompatible with building a relocatable object
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
I'll either fix the Solaris driver code not to pass `-Bdynamic -e _start` with 
`-r` or do a full comparison of `Gnu.cpp` and `Solaris.cpp` to check for 
undesirable differences.

However, for the patch at hand this is moot while
```
$ flang-new -r -o hello-r.o hello.o
flang-new: error: unknown argument: '-r'
```

I wonder how to proceed with the patch at hand.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-20 Thread Brad Smith via cfe-commits

brad0 wrote:

> On top of that, Solaris `clang` doesn't handle `-r` correctly, passing `-e 
> _start -Bdynamic` to `ld`, which makes it choke...

Looking at the GNU linker it seems to ignore -Bdynamic once -r is specified. 
Not sure how LLD handles things. The OpenBSD driver might need adjustments for 
the same thing.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Rainer Orth via cfe-commits

rorth wrote:

I'd argue that handling the Flang runtime libs like C++ is the right thing to 
do here.  However, `flang-new` currently rejects all of `-r`, `-nostdlib`, and 
`-nodefaultlibs` on both Linux and Solaris.  On top of that, Solaris `clang` 
doesn't handle `-r` correctly, passing `-e _start -Bdynamic` to `ld`, which 
makes it choke...

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 deleted https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 deleted https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 deleted https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

brad0 wrote:

Because of where the chunk is being added in the Solaris ToolChain (and what I 
had in my tree for *BSD's) it is checking for the ```nostdlib, nodefaultlibs, 
or r``` flags, where as the Gnu path does not. I just want to make sure the 
behavior is consistent.

tools::gnutools::Linker::ConstructJob

```
  if (D.CCCIsCXX() &&
  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
   options::OPT_r)) {
if (ToolChain.ShouldLinkCXXStdlib(Args)) {
  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
 !Args.hasArg(options::OPT_static);
  if (OnlyLibstdcxxStatic)
CmdArgs.push_back("-Bstatic");
  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
  if (OnlyLibstdcxxStatic)
CmdArgs.push_back("-Bdynamic");
}
CmdArgs.push_back("-lm");
  }

  // Silence warnings when linking C code with a C++ '-stdlib' argument.
  Args.ClaimAllArgs(options::OPT_stdlib_EQ);

  // Additional linker set-up and flags for Fortran. This is required in order
  // to generate executables. As Fortran runtime depends on the C runtime,
  // these dependencies need to be listed before the C runtime below (i.e.
  // AddRuntTimeLibs).
  if (D.IsFlangMode()) {
addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
addFortranRuntimeLibs(ToolChain, CmdArgs);
CmdArgs.push_back("-lm");
  }
```

solaris::Linker::ConstructJob

```
  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
   options::OPT_r)) {
if (D.CCCIsCXX()) {
  if (getToolChain().ShouldLinkCXXStdlib(Args))
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
  CmdArgs.push_back("-lm");
}
// Additional linker set-up and flags for Fortran. This is required in order
// to generate executables. As Fortran runtime depends on the C runtime,
// these dependencies need to be listed before the C runtime below.
if (D.IsFlangMode()) {
  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
  addFortranRuntimeLibs(getToolChain(), CmdArgs);
  CmdArgs.push_back("-lm");
}
```

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 deleted https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

brad0 wrote:

One thing to add to this. I noticed the Gnu addition does not check for 
`nostdlib, nodefaultlibs, or r` flags like the C++ library chunk does. With the 
proposed diff and what I had initially being right under the C++ chunk in the 
Solaris and *BSD ToolChain they would be checking for said flags.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 deleted https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

brad0 wrote:

One thing to add to this. I noticed the Gnu addition does not check for 
`nostdlib, nodefaultlibs, or r` flags like the C++ library chunk does. With the 
proposed diff and what I had initially being right under the C++ chunk in the 
Solaris and *BSD ToolChain they would be checking for said flags.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits

https://github.com/brad0 edited https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

> My comment was not about the test.

My original comment in this thread was specifically about:
```
! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
```
in 
[linker-flags.f90](https://github.com/llvm/llvm-project/pull/65644/files/31bdd3477d9f54996b71584598bdd75f2cef31db#diff-4c1ccab047579d6c5abdd4f4fe3e1947e6d344e7e0c3e04048e72d61f43cbb3f)
 :)

[nit] Perhaps you could start a separate thread? GitHub UI is so confusing ...

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

brad0 wrote:

> @brad0 , perhaps I misunderstood your comment, but "linker-flags.f90"checks 
> for things specific to LLVM Flang. Generic stuff that applies to C++ and 
> Fortran should be tested in Clang (i.e. where `clangDriver` library is 
> located).

My comment was not about the test. Because of where the chunk is being added in 
the Solaris ToolChain (and what I had in my tree for *BSD's) it is checking for 
the ```nostdlib, nodefaultlibs, or r``` flags, where as the Gnu path does not. 
I just want to make sure the behavior is consistent.

tools::gnutools::Linker::ConstructJob

```
  if (D.CCCIsCXX() &&
  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
   options::OPT_r)) {
if (ToolChain.ShouldLinkCXXStdlib(Args)) {
  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
 !Args.hasArg(options::OPT_static);
  if (OnlyLibstdcxxStatic)
CmdArgs.push_back("-Bstatic");
  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
  if (OnlyLibstdcxxStatic)
CmdArgs.push_back("-Bdynamic");
}
CmdArgs.push_back("-lm");
  }

  // Silence warnings when linking C code with a C++ '-stdlib' argument.
  Args.ClaimAllArgs(options::OPT_stdlib_EQ);

  // Additional linker set-up and flags for Fortran. This is required in order
  // to generate executables. As Fortran runtime depends on the C runtime,
  // these dependencies need to be listed before the C runtime below (i.e.
  // AddRuntTimeLibs).
  if (D.IsFlangMode()) {
addFortranRuntimeLibraryPath(ToolChain, Args, CmdArgs);
addFortranRuntimeLibs(ToolChain, CmdArgs);
CmdArgs.push_back("-lm");
  }
```

solaris::Linker::ConstructJob

```
  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
   options::OPT_r)) {
if (D.CCCIsCXX()) {
  if (getToolChain().ShouldLinkCXXStdlib(Args))
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
  CmdArgs.push_back("-lm");
}
// Additional linker set-up and flags for Fortran. This is required in order
// to generate executables. As Fortran runtime depends on the C runtime,
// these dependencies need to be listed before the C runtime below.
if (D.IsFlangMode()) {
  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
  addFortranRuntimeLibs(getToolChain(), CmdArgs);
  CmdArgs.push_back("-lm");
}
```



https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

@brad0 , perhaps I misunderstood your comment, but "linker-flags.f90"checks for 
things specific to LLVM Flang. Generic stuff that applies to C++ and Fortran 
should be tested in Clang (i.e. where `clangDriver` library is located).

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

brad0 wrote:

One thing to add to this. I noticed the Gnu addition does not check for 
`nostdlib, nodefaultlibs, or r` flags like the C++ library chunk does. With the 
proposed diff and what I had initially being right under the C++ chunk in the 
Solaris and *BSD ToolChain they would be checking for said flags.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Brad Smith via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

brad0 wrote:

> Add FreeBSD, OpenBSD, ... whenever they arrive?

Bumping into this PR that'll be happening much sooner for all of the *BSD's 
now. 



https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-14 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

I would consolidate like you suggested. Perhaps the common prefix cold be 
"ALL-RT-LIBS" or "FLANG-RT-LIBS"? Suggestions welcome.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-14 Thread Rainer Orth via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

rorth wrote:

@banach-space How should we proceed with this one?  Really introduce separate 
labels for each OS, even if the checks are identical?  Or consolidate labels as 
I suggested?


https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-10 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

Sure, reducing duplication would be nice. Could you propose something?

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits

https://github.com/rorth edited https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

rorth wrote:

True, but how many more copies of the same patterns do we want?  Add FreeBSD, 
OpenBSD, ... whenever they arrive?  Isn't the common patternwith or without `-lm`?  How about putting the first under 
one label and the `-lm` part under another, used where appropriate?

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

Solaris is not GNU ;-) Please use a dedicated prefix.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth review_requested 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/65644:

I noticed that `flang-new` cannot link Fortran executables on Solaris since the 
runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase is 
augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth review_requested 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth review_requested 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits