[PATCH] D53238: [Driver] Add -static-{rtlib, stdlib} and make -static-{libgcc, libstdc++} their aliases

2018-12-04 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Also,  Sorry for the long time to reply, I don't LLVM often enough :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53238/new/

https://reviews.llvm.org/D53238



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


[PATCH] D53238: [Driver] Add -static-{rtlib, stdlib} and make -static-{libgcc, libstdc++} their aliases

2018-12-04 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Seems like a better solution than what I had in D37726 
.
I'm not sully sure on the naming so I think someone else should also sign off 
on this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53238/new/

https://reviews.llvm.org/D53238



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


[PATCH] D37726: clang: alias -static-{libstdc++, libgcc} for LLVM variants

2018-12-04 Thread Martell Malone via Phabricator via cfe-commits
martell abandoned this revision.
martell added a comment.

Dropping in favour of D53238 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D37726/new/

https://reviews.llvm.org/D37726



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


[PATCH] D45505: [WIP] [GCC] Match a GCC version with a patch suffix without a third version component

2018-04-22 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D45505



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


[PATCH] D45152: [MinGW] Add option for disabling looking for a mingw gcc in PATH

2018-04-04 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@mstorsjo I would much prefer to detect the clang sysroot first and if that 
exists just ignore the gcc one.
Most of the time clang and gcc will be in the same bin folder and in the case 
where the clang sysroot with mingw prefix folders is not found we can just 
default back to the default gcc behavior.
This should cover the use case for existing gcc users while not blocking us to 
move forward with clang only toolchains.
If someone really wants to ignore the clang sysroot with mingw folders we could 
add a flag for that and not the other way around.
What are your thoughts here?


Repository:
  rC Clang

https://reviews.llvm.org/D45152



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2018-03-08 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.
Herald added a subscriber: mgrang.

ping @marsupial


https://reviews.llvm.org/D35103



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


[PATCH] D41597: CMAKE: disable -mbig-obj for mingw clang asm

2018-02-07 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Updated to just ignore the flag just like how clang-cl does for /bigobj


Repository:
  rC Clang

https://reviews.llvm.org/D41597



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


[PATCH] D41597: CMAKE: disable -mbig-obj for mingw clang asm

2018-02-07 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 133374.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D41597

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1768,6 +1768,7 @@
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
+def mbig_obj : Flag<["-"], "mbig-obj">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, 
Group;
 def mno_default_build_attributes : Joined<["-"], 
"mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, 
Group;


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1768,6 +1768,7 @@
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
+def mbig_obj : Flag<["-"], "mbig-obj">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, Group;
 def mno_default_build_attributes : Joined<["-"], "mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41809: Clang counterpart change for fuzzer FreeBSD support

2018-01-13 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.

Given that https://reviews.llvm.org/rL322380 has been merged this seems good to 
me.


https://reviews.llvm.org/D41809



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

I also want to note a small addition armb and thumbeb for NetBSD.
They were missed in the previous version.
Just waiting for tests to pass now.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@mstorsjo yup, I added a comment on the commit about the failure here 
https://reviews.llvm.org/rL319294
I have already fixed both issues.
Will re apply shortly.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319294: Toolchain: Normalize dwarf, sjlj and seh eh 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D39673?vs=124695=124696#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  cfe/trunk/docs/ClangCommandLineReference.rst
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/lib/Basic/Targets/OSTargets.cpp
  cfe/trunk/lib/Basic/Targets/OSTargets.h
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.h
  cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
  cfe/trunk/lib/Driver/ToolChains/FreeBSD.h
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
  cfe/trunk/lib/Driver/ToolChains/MinGW.h
  cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
  cfe/trunk/lib/Driver/ToolChains/NetBSD.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c
  cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  cfe/trunk/test/Preprocessor/arm-target-features.c
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -397,10 +397,9 @@
 return llvm::DebuggerKind::GDB;
   }
 
-  /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
-  virtual bool UseSjLjExceptions(const llvm::opt::ArgList ) const {
-return false;
-  }
+  /// GetExceptionModel - Return the tool chain exception model.
+  virtual llvm::ExceptionHandling
+  GetExceptionModel(const llvm::opt::ArgList ) const;
 
   /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
   virtual bool SupportsEmbeddedBitcode() const {
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -800,8 +800,12 @@
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>;
 def fexceptions : Flag<["-"], "fexceptions">, Group, Flags<[CC1Option]>,
   HelpText<"Enable support for exception handling">;
+def fdwarf_exceptions : Flag<["-"], "fdwarf-exceptions">, Group,
+  Flags<[CC1Option]>, HelpText<"Use DWARF style exceptions">;
 def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">, Group,
   Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
+def fseh_exceptions : Flag<["-"], "fseh-exceptions">, Group,
+  Flags<[CC1Option]>, HelpText<"Use SEH style exceptions">;
 def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">,
 Group;
 def : Flag<["-"], "fexpensive-optimizations">, Group;
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -124,7 +124,9 @@
 LANGOPT(Exceptions, 1, 0, "exception handling")
 LANGOPT(ObjCExceptions, 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
+LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
 LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
+LANGOPT(SEHExceptions , 1, 0, "SEH .xdata exception handling")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")
 LANGOPT(RTTI  , 1, 1, "run-time type information")
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

landing this as it was previous approved by reid in this state and again re 
checked by martin.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 124695.
martell added a comment.

- disregard my last comment, lets go with seh on all windows targets.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/FreeBSD.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.cpp
  lib/Driver/ToolChains/NetBSD.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -677,8 +677,14 @@
 Builder.defineMacro("__EXCEPTIONS");
   if (!LangOpts.MSVCCompat && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
+
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  else if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
+  else if (LangOpts.DWARFExceptions &&
+  (TI.getTriple().isThumb() || TI.getTriple().isARM()))
+Builder.defineMacro("__ARM_DWARF_EH__");
 
   if (LangOpts.Deprecated)
 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: lib/Driver/ToolChain.cpp:458
+if (Triple.getArch() == llvm::Triple::x86)
+  return llvm::ExceptionHandling::DwarfCFI;
+else

mstorsjo wrote:
> I'd suggest braces around the outer if statement.
> 
> But is there any point to this default fallback here at all? Dwarf isn't 
> right for x86 for MSVC, and we set the right defaults for all the MinGW cases 
> in that driver in any case. So isn't it enough to just return None always 
> here, or possibly WinEH for all windows cases?
Won't need braces with the change I am about to make.

The previous check was `getArch() == llvm::Triple::x86_64` then use seh.
This didn't take into account arm or aarch64 so I flipped this.

I read the wrong llvm class for  `llvm::Triple::x86` `X86MCAsmInfoGNUCOFF`
It should have been `X86MCAsmInfoMicrosoft` I looked at.
```
  if (Triple.getArch() == Triple::x86_64) {
PrivateGlobalPrefix = ".L";
PrivateLabelPrefix = ".L";
CodePointerSize = 8;
WinEHEncodingType = WinEH::EncodingType::Itanium;
  } else {
// 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
// a place holder that the Windows EHStreamer looks for to suppress CFI
// output. In particular, usesWindowsCFI() returns false.
WinEHEncodingType = WinEH::EncodingType::X86;
  }

  ExceptionsType = ExceptionHandling::WinEH;
```
I think None in the case of x86 is the behavior that was present previously so 
I am going to revert from dwarf to none.

https://www.google.com/patents/US5628016
That borland patent has long since expired now and seh is the default in llvm 
for x86 so we can do seh on x86 for clang but I will leave that to a different 
patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-28 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 124692.
martell added a comment.

address reid's comment
update to HEAD


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/FreeBSD.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.cpp
  lib/Driver/ToolChains/NetBSD.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -677,8 +677,14 @@
 Builder.defineMacro("__EXCEPTIONS");
   if (!LangOpts.MSVCCompat && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
+
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  else if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
+  else if (LangOpts.DWARFExceptions &&
+  (TI.getTriple().isThumb() || TI.getTriple().isARM()))
+Builder.defineMacro("__ARM_DWARF_EH__");
 
   if (LangOpts.Deprecated)
 Builder.defineMacro("__DEPRECATED");
Index: 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-22 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D39673#931861, @rnk wrote:

> We have to know the EH model before pre-processing, and that shouldn't rely 
> on LLVM TargetOptions. We can probably reuse the `llvm::ExceptionHandling` 
> enum instead of these various overlapping booleans, if that's the direction 
> you want to go. However, I don't see how we can get away from the clang 
> toolchain knowing the default EH model for each target.


I ended up folding USESjLjExceptions into a GetExceptionModel function that 
returns the llvm::ExceptionHandling.
Reid you are right that clang needed to know some targets beforehand, this is 
especially obvious for the various apple devices. watch and co.

relying on LLVM TargetOptions is much better for platforms like windows
rather then checking `T.isOSWindows() && T.getArch() == llvm::Triple::x86_64` 
to decide on enabling SEH I opted to do a best effort attempt to check what the 
default is much like how cc1as does.
the difference being if it fails we just specify the default as none giving us 
the following pattern.

1. set eh based no user flags passed into clang
2. if no flags passed check the toolchain defaults,
3. if no toolchain default then check llvm,
4. if we can not determine if it is a supported triple default to None.

I also addressed Martin's concern in the folding by adding `| 
LangOpts.DWARFExceptions` and no longer have to specifically check for mingw or 
netbsd.

Sorry for the noise on this, I just want to make sure we get the best 
functionality on this while ensuring it is future proof for other model.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-22 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123883.
martell edited the summary of this revision.
martell added a comment.
Herald added subscribers: kristof.beyls, emaste, aemerson.

fold USESjLjExceptions into GetExceptionModel.
do a best effort to check the llvm default exception model for the triple if 
the toolchain does not specify.
(mostly based on the cc1_as code)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/FreeBSD.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.cpp
  lib/Driver/ToolChains/NetBSD.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -677,8 +677,14 @@
 Builder.defineMacro("__EXCEPTIONS");
   if (!LangOpts.MSVCCompat && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
+
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  else if (LangOpts.SEHExceptions)
+

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Just as a note there is still a lot to be desired here. I do not particularly 
like the `UseSEHExceptions` function default and the actual macro definition 
guards should be based on the current `ExceptionModel` because we set that in 
`lib/CodeGen/BackendUtil.cpp`. This way we do not need to have some silly 
default of x64 && windows for UseSEHExceptions and can rely on the llvm backend 
defaults but override within the driver we want like the apple targets do for 
sjlj. This does for now keep the current functionality which giving us a flag 
to override which is the goal of this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D39673#929986, @mstorsjo wrote:

> I'm not sure if this is the right thing to do. Since the exception handling 
> model more or less also defines what ABI the code conforms to, I can see it 
> being useful to know what exception handling mode is intended to be used, 
> even if compiling plain C code without exceptions enabled. E.g. when building 
> libunwind, some of the C sources there have ifdefs that check for 
> `__USING_SJLJ_EXCEPTIONS__` and/or `__ARM_DWARF_EH__`. With this change, one 
> has to manually start specifying it when building libunwind, to match 
> whatever the default and/or manually chosen exception handling model is.


It seems reasonable to me that one would specify `-fexceptions` when building  
c sources to get the macro for the exceptions, libunwind included, but yes 
right now there are c sources in `libunwind` that this would break and probably 
other libraries that have c sources that check unconditionally. This is not an 
issue for c++ as `-fexceptions` is enabled by default.

This is a little beyond the scope of what I am trying to achieve in this patch 
though and should be in a different differential after libunwind adds 
-fexceptions when building it's c sources, if we go that route.
For now I have update this patch to HEAD and reverted back to using the model 
macros defines independent of `-fexceptions` as you suggested.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123758.
martell added a comment.

updated to HEAD.
added a NOT msvc test


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -677,8 +677,14 @@
 Builder.defineMacro("__EXCEPTIONS");
   if (!LangOpts.MSVCCompat && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
+
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  else if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
+  else if ((TI.getTriple().isThumb() || TI.getTriple().isARM()) &&
+  (TI.getTriple().isOSNetBSD() || TI.getTriple().isOSWindows()))
+Builder.defineMacro("__ARM_DWARF_EH__");
 
   if (LangOpts.Deprecated)
 Builder.defineMacro("__DEPRECATED");
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2139,7 +2139,18 @@
   Opts.Exceptions = 

[PATCH] D40285: [MINGW] normalize WIN32 macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318755: [MINGW] normalize WIN32 macros (authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D40285?vs=123751=123755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40285

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Basic/Targets.h
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/lib/Basic/Targets/AArch64.h
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/lib/Basic/Targets/OSTargets.h
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/test/Preprocessor/predefined-macros.c

Index: cfe/trunk/lib/Basic/Targets.h
===
--- cfe/trunk/lib/Basic/Targets.h
+++ cfe/trunk/lib/Basic/Targets.h
@@ -40,7 +40,7 @@
  bool Tuning = true);
 
 LLVM_LIBRARY_VISIBILITY
-void addMinGWDefines(const clang::LangOptions ,
+void addMinGWDefines(const llvm::Triple , const clang::LangOptions ,
  clang::MacroBuilder );
 
 LLVM_LIBRARY_VISIBILITY
Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -474,8 +474,6 @@
 void MicrosoftARM64TargetInfo::getVisualStudioDefines(
 const LangOptions , MacroBuilder ) const {
   WindowsTargetInfo::getVisualStudioDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
-  Builder.defineMacro("_WIN64", "1");
   Builder.defineMacro("_M_ARM64", "1");
 }
 
@@ -491,17 +489,6 @@
   TheCXXABI.set(TargetCXXABI::GenericAArch64);
 }
 
-void MinGWARM64TargetInfo::getTargetDefines(const LangOptions ,
-MacroBuilder ) const {
-  WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
-  Builder.defineMacro("_WIN64", "1");
-  Builder.defineMacro("WIN32", "1");
-  Builder.defineMacro("WIN64", "1");
-  addMinGWDefines(Opts, Builder);
-}
-
-
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
Index: cfe/trunk/lib/Basic/Targets/ARM.cpp
===
--- cfe/trunk/lib/Basic/Targets/ARM.cpp
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp
@@ -999,11 +999,8 @@
 void MinGWARMTargetInfo::getTargetDefines(const LangOptions ,
   MacroBuilder ) const {
   WindowsARMTargetInfo::getTargetDefines(Opts, Builder);
-  DefineStd(Builder, "WIN32", Opts);
-  DefineStd(Builder, "WINNT", Opts);
   Builder.defineMacro("_ARM_");
   Builder.defineMacro("__ARM_DWARF_EH__");
-  addMinGWDefines(Opts, Builder);
 }
 
 CygwinARMTargetInfo::CygwinARMTargetInfo(const llvm::Triple ,
Index: cfe/trunk/lib/Basic/Targets/AArch64.h
===
--- cfe/trunk/lib/Basic/Targets/AArch64.h
+++ cfe/trunk/lib/Basic/Targets/AArch64.h
@@ -122,9 +122,6 @@
 : public WindowsARM64TargetInfo {
 public:
   MinGWARM64TargetInfo(const llvm::Triple , const TargetOptions );
-
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
Index: cfe/trunk/lib/Basic/Targets/OSTargets.h
===
--- cfe/trunk/lib/Basic/Targets/OSTargets.h
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h
@@ -572,6 +572,11 @@
   void getOSDefines(const LangOptions , const llvm::Triple ,
 MacroBuilder ) const override {
 Builder.defineMacro("_WIN32");
+if (Triple.isArch64Bit())
+  Builder.defineMacro("_WIN64");
+if (Triple.isWindowsGNUEnvironment())
+  addMinGWDefines(Triple, Opts, Builder);
+
   }
   void getVisualStudioDefines(const LangOptions ,
   MacroBuilder ) const {
Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -410,11 +410,6 @@
 ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
 : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
-
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override {
-WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  }
 };
 
 // x86-32 Windows Visual Studio target
@@ -451,10 +446,7 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
-DefineStd(Builder, "WIN32", Opts);
-DefineStd(Builder, "WINNT", Opts);
 Builder.defineMacro("_X86_");
-addMinGWDefines(Opts, Builder);
   }
 };
 
@@ -658,12 +650,6 @@
 

[PATCH] D40285: [MINGW] normalize WIN32 macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@mstorsjo can you confirm this new order looks good to you?


Repository:
  rL LLVM

https://reviews.llvm.org/D40285



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


[PATCH] D40285: [MINGW] normalize WIN32 macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123751.
martell added a comment.

reorder test checks


Repository:
  rL LLVM

https://reviews.llvm.org/D40285

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets.h
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -193,19 +193,77 @@
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0
 
+// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
+
+// CHECK-X86-WIN-NOT: #define WIN32 1
+// CHECK-X86-WIN-NOT: #define WIN64 1
+// CHECK-X86-WIN-NOT: #define WINNT 1
+// CHECK-X86-WIN: #define _WIN32 1
+// CHECK-X86-WIN-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple thumbv7-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-WIN
+
+// CHECK-ARM-WIN-NOT: #define WIN32 1
+// CHECK-ARM-WIN-NOT: #define WIN64 1
+// CHECK-ARM-WIN-NOT: #define WINNT 1
+// CHECK-ARM-WIN: #define _WIN32 1
+// CHECK-ARM-WIN-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple x86_64-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-WIN
+
+// CHECK-AMD64-WIN-NOT: #define WIN32 1
+// CHECK-AMD64-WIN-NOT: #define WIN64 1
+// CHECK-AMD64-WIN-NOT: #define WINNT 1
+// CHECK-AMD64-WIN: #define _WIN32 1
+// CHECK-AMD64-WIN: #define _WIN64 1
+
 // RUN: %clang_cc1 -triple aarch64-windows %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-WIN
 
+// CHECK-ARM64-WIN-NOT: #define WIN32 1
+// CHECK-ARM64-WIN-NOT: #define WIN64 1
+// CHECK-ARM64-WIN-NOT: #define WINNT 1
 // CHECK-ARM64-WIN: #define _M_ARM64 1
 // CHECK-ARM64-WIN: #define _WIN32 1
 // CHECK-ARM64-WIN: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
+
+// CHECK-X86-MINGW: #define WIN32 1
+// CHECK-X86-MINGW-NOT: #define WIN64 1
+// CHECK-X86-MINGW: #define WINNT 1
+// CHECK-X86-MINGW: #define _WIN32 1
+// CHECK-X86-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple thumbv7-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-MINGW
+
+// CHECK-ARM-MINGW: #define WIN32 1
+// CHECK-ARM-MINGW-NOT: #define WIN64 1
+// CHECK-ARM-MINGW: #define WINNT 1
+// CHECK-ARM-MINGW: #define _WIN32 1
+// CHECK-ARM-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
+
+// CHECK-AMD64-MINGW: #define WIN32 1
+// CHECK-AMD64-MINGW: #define WIN64 1
+// CHECK-AMD64-MINGW: #define WINNT 1
+// CHECK-AMD64-MINGW: #define _WIN32 1
+// CHECK-AMD64-MINGW: #define _WIN64 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
 // CHECK-ARM64-MINGW: #define WIN64 1
+// CHECK-ARM64-MINGW: #define WINNT 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -410,11 +410,6 @@
 ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
 : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
-
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override {
-WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  }
 };
 
 // x86-32 Windows Visual Studio target
@@ -451,10 +446,7 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
-DefineStd(Builder, "WIN32", Opts);
-DefineStd(Builder, "WINNT", Opts);
 Builder.defineMacro("_X86_");
-addMinGWDefines(Opts, Builder);
   }
 };
 
@@ -658,12 +650,6 @@
 IntPtrType = SignedLongLong;
   }
 
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override {
-WindowsTargetInfo::getTargetDefines(Opts, Builder);
-Builder.defineMacro("_WIN64");
-  }
-
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
@@ -726,9 +712,6 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_64TargetInfo::getTargetDefines(Opts, 

[PATCH] D40285: [MINGW] normalize WIN32 macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123747.
martell edited the summary of this revision.
martell added a comment.

[MINGW] normalize WIN32 macros


Repository:
  rL LLVM

https://reviews.llvm.org/D40285

Files:
  lib/Basic/Targets.cpp
  lib/Basic/Targets.h
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -193,19 +193,79 @@
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0
 
+// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
+
+// CHECK-X86-WIN: #define _WIN32 1
+// CHECK-X86-WIN-NOT: #define _WIN64 1
+// CHECK-X86-WIN-NOT: #define WINNT 1
+// CHECK-X86-WIN-NOT: #define WIN32 1
+// CHECK-X86-WIN-NOT: #define WIN64 1
+
+
+// RUN: %clang_cc1 -triple thumbv7-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-WIN
+
+// CHECK-ARM-WIN: #define _WIN32 1
+// CHECK-ARM-WIN-NOT: #define _WIN64 1
+// CHECK-ARM-WIN-NOT: #define WINNT 1
+// CHECK-ARM-WIN-NOT: #define WIN32 1
+// CHECK-ARM-WIN-NOT: #define WIN64 1
+
+
+// RUN: %clang_cc1 -triple x86_64-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-WIN
+
+// CHECK-AMD64-WIN: #define _WIN32 1
+// CHECK-AMD64-WIN: #define _WIN64 1
+// CHECK-AMD64-WIN-NOT: #define WINNT 1
+// CHECK-AMD64-WIN-NOT: #define WIN32 1
+// CHECK-AMD64-WIN-NOT: #define WIN64 1
+
 // RUN: %clang_cc1 -triple aarch64-windows %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-WIN
 
 // CHECK-ARM64-WIN: #define _M_ARM64 1
 // CHECK-ARM64-WIN: #define _WIN32 1
 // CHECK-ARM64-WIN: #define _WIN64 1
+// CHECK-ARM64-WIN-NOT: #define WINNT 1
+// CHECK-ARM64-WIN-NOT: #define WIN32 1
+// CHECK-ARM64-WIN-NOT: #define WIN64 1
+
+// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
+
+// CHECK-X86-MINGW: #define WIN32 1
+// CHECK-X86-MINGW: #define WINNT 1
+// CHECK-X86-MINGW: #define _WIN32 1
+// CHECK-X86-MINGW-NOT: #define WIN64 1
+// CHECK-X86-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple thumbv7-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-MINGW
+
+// CHECK-ARM-MINGW: #define WIN32 1
+// CHECK-ARM-MINGW: #define WINNT 1
+// CHECK-ARM-MINGW: #define _WIN32 1
+// CHECK-ARM-MINGW-NOT: #define WIN64 1
+// CHECK-ARM-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
+
+// CHECK-AMD64-MINGW: #define WIN32 1
+// CHECK-AMD64-MINGW: #define WIN64 1
+// CHECK-AMD64-MINGW: #define WINNT 1
+// CHECK-AMD64-MINGW: #define _WIN32 1
+// CHECK-AMD64-MINGW: #define _WIN64 1
 
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
 // CHECK-ARM64-MINGW: #define WIN64 1
+// CHECK-ARM64-MINGW: #define WINNT 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -410,11 +410,6 @@
 ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
 : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
-
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override {
-WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  }
 };
 
 // x86-32 Windows Visual Studio target
@@ -451,10 +446,7 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
-DefineStd(Builder, "WIN32", Opts);
-DefineStd(Builder, "WINNT", Opts);
 Builder.defineMacro("_X86_");
-addMinGWDefines(Opts, Builder);
   }
 };
 
@@ -658,12 +650,6 @@
 IntPtrType = SignedLongLong;
   }
 
-  void getTargetDefines(const LangOptions ,
-MacroBuilder ) const override {
-WindowsTargetInfo::getTargetDefines(Opts, Builder);
-Builder.defineMacro("_WIN64");
-  }
-
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
@@ -726,9 +712,6 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override 

[PATCH] D40285: [MS] AARCH64 cleanup default WIN macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D40285#931248, @mstorsjo wrote:

> I'm a little divided - either we remove both WIN32 and WIN64 from all mingw 
> configurations, or we add the missing WIN32 for x86_64 mingw. Removing would 
> be the strictly correct thing to do, but I'm sure it will break code that 
> used to work before (even though it's wrong to rely on the unprefixed one).


looking at different `windef.h` I see - specifically ReactOS

  #ifndef WIN32
  #define WIN32
  #endif

I don't have MSVC off hand to check if it is there but I do remember MSVC 
projects used to pass `/D "WIN32"` so having them might make sense also.
I'm going to try include them and fold all the code for the different arch's 
for mingw in a moment


Repository:
  rL LLVM

https://reviews.llvm.org/D40285



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


[PATCH] D40285: [MS] AARCH64 cleanup default WIN macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

... also WINNT was defined for X86 so I just added that to note it.
what do you suggest we do with that one.


Repository:
  rL LLVM

https://reviews.llvm.org/D40285



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


[PATCH] D40285: [MS] AARCH64 cleanup default WIN macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D40285#931241, @mstorsjo wrote:

> ... so in general I wouldn't mind doing a change like this, but I'd like to 
> make it consistent on ARM, i386 and x86_64 at the same time in that case, 
> instead of just changing aarch64.


Thanks for the quick feedback :)
The easy one is to get rid of WIN64 because gcc doesn't even do that for mingw.
What are your thoughts here on WIN32, I would prefer to move it.
I remember a long time ago a lot of projects moved to _WIN32 when they 
discovered that it was not supposed to be defined.
I updated the diff to reflect removing WIN64


Repository:
  rL LLVM

https://reviews.llvm.org/D40285



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


[PATCH] D40285: [MS] AARCH64 cleanup default WIN macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123728.

Repository:
  rL LLVM

https://reviews.llvm.org/D40285

Files:
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/X86.h
  test/Preprocessor/predefined-macros.c


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -200,12 +200,20 @@
 // CHECK-ARM64-WIN: #define _WIN32 1
 // CHECK-ARM64-WIN: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
+
+// CHECK-AMD64-MINGW: #define WIN32 1
+// CHECK-AMD64-MINGW: #define WINNT 1
+// CHECK-AMD64-MINGW: #define _WIN32 1
+// CHECK-AMD64-MINGW: #define _WIN64 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
-// CHECK-ARM64-MINGW: #define WIN64 1
+// CHECK-ARM64-MINGW: #define WINNT 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -726,7 +726,6 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
-DefineStd(Builder, "WIN64", Opts);
 Builder.defineMacro("__MINGW64__");
 addMinGWDefines(Opts, Builder);
 
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -474,7 +474,6 @@
 void MicrosoftARM64TargetInfo::getVisualStudioDefines(
 const LangOptions , MacroBuilder ) const {
   WindowsTargetInfo::getVisualStudioDefines(Opts, 
Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
   Builder.defineMacro("_M_ARM64", "1");
 }
@@ -494,10 +493,9 @@
 void MinGWARM64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
   WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
+  DefineStd(Builder, "WIN32", Opts);
+  DefineStd(Builder, "WINNT", Opts);
   Builder.defineMacro("_WIN64", "1");
-  Builder.defineMacro("WIN32", "1");
-  Builder.defineMacro("WIN64", "1");
   addMinGWDefines(Opts, Builder);
 }
 


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -200,12 +200,20 @@
 // CHECK-ARM64-WIN: #define _WIN32 1
 // CHECK-ARM64-WIN: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
+
+// CHECK-AMD64-MINGW: #define WIN32 1
+// CHECK-AMD64-MINGW: #define WINNT 1
+// CHECK-AMD64-MINGW: #define _WIN32 1
+// CHECK-AMD64-MINGW: #define _WIN64 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
 // CHECK-ARM64-MINGW: #define WIN32 1
-// CHECK-ARM64-MINGW: #define WIN64 1
+// CHECK-ARM64-MINGW: #define WINNT 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -726,7 +726,6 @@
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
-DefineStd(Builder, "WIN64", Opts);
 Builder.defineMacro("__MINGW64__");
 addMinGWDefines(Opts, Builder);
 
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -474,7 +474,6 @@
 void MicrosoftARM64TargetInfo::getVisualStudioDefines(
 const LangOptions , MacroBuilder ) const {
   WindowsTargetInfo::getVisualStudioDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
   Builder.defineMacro("_M_ARM64", "1");
 }
@@ -494,10 +493,9 @@
 void MinGWARM64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
   WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
+  DefineStd(Builder, "WIN32", Opts);
+  DefineStd(Builder, "WINNT", Opts);
   Builder.defineMacro("_WIN64", "1");

[PATCH] D40285: [MS] AARCH64 cleanup default WIN macros

2017-11-21 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.
Herald added subscribers: kristof.beyls, javed.absar, rengolin, aemerson.

_WIN32 is already defined in lib/Basic/Targets/OSTargets.h
WIN32 and WIN64 are not real definitions they are typically
defined by the system headers,  _WIN32 and _WIN64 are the
compiler definitions.


Repository:
  rL LLVM

https://reviews.llvm.org/D40285

Files:
  lib/Basic/Targets/AArch64.cpp
  test/Preprocessor/predefined-macros.c


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -204,8 +204,6 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
-// CHECK-ARM64-MINGW: #define WIN32 1
-// CHECK-ARM64-MINGW: #define WIN64 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -474,7 +474,6 @@
 void MicrosoftARM64TargetInfo::getVisualStudioDefines(
 const LangOptions , MacroBuilder ) const {
   WindowsTargetInfo::getVisualStudioDefines(Opts, 
Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
   Builder.defineMacro("_M_ARM64", "1");
 }
@@ -494,10 +493,7 @@
 void MinGWARM64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
   WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
-  Builder.defineMacro("WIN32", "1");
-  Builder.defineMacro("WIN64", "1");
   addMinGWDefines(Opts, Builder);
 }
 


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -204,8 +204,6 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
 // CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
-// CHECK-ARM64-MINGW: #define WIN32 1
-// CHECK-ARM64-MINGW: #define WIN64 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -474,7 +474,6 @@
 void MicrosoftARM64TargetInfo::getVisualStudioDefines(
 const LangOptions , MacroBuilder ) const {
   WindowsTargetInfo::getVisualStudioDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
   Builder.defineMacro("_M_ARM64", "1");
 }
@@ -494,10 +493,7 @@
 void MinGWARM64TargetInfo::getTargetDefines(const LangOptions ,
 MacroBuilder ) const {
   WindowsTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("_WIN32", "1");
   Builder.defineMacro("_WIN64", "1");
-  Builder.defineMacro("WIN32", "1");
-  Builder.defineMacro("WIN64", "1");
   addMinGWDefines(Opts, Builder);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-19 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:684
+else if (TI.getTriple().isThumb() || TI.getTriple().isARM())
+  Builder.defineMacro("__ARM_DWARF_EH__");
+  }

mstorsjo wrote:
> Won't this start setting this define also on platforms where ARM EHABI is the 
> default? (I.e. all ELF platforms except netbsd)?
It will set it on any arm / thumb platform where exceptions are enabled and the 
current model is dwarf.
This includes netbsd. The issue we have is that apple set this unconditionally 
for their watch platform.

I'm wondering if we should put this behind a `!apple` guard or just add an `if 
windows or netbsd` guard.

Or is it okay to just generally have this macro on all platforms where dwarf is 
exception model and the target is arm?



Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39588: Distro: initial support for alpine

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318608: [Driver] add initial support for alpine linux 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D39588?vs=121462=123488#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39588

Files:
  cfe/trunk/include/clang/Driver/Distro.h
  cfe/trunk/lib/Driver/Distro.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/test/Driver/pic.c


Index: cfe/trunk/include/clang/Driver/Distro.h
===
--- cfe/trunk/include/clang/Driver/Distro.h
+++ cfe/trunk/include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return DistroVal == AlpineLinux;
+  }
+
   /// @}
 };
 
Index: cfe/trunk/test/Driver/pic.c
===
--- cfe/trunk/test/Driver/pic.c
+++ cfe/trunk/test/Driver/pic.c
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -nopie -pie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // Darwin is a beautiful and unique snowflake when it comes to these flags.
 // When targeting a 32-bit darwin system, only level 2 is supported. On 64-bit
 // targets, there is simply nothing you can do, there is no PIE, there is only
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -210,7 +210,12 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
@@ -812,7 +817,7 @@
 
 bool Linux::isPIEDefault() const {
   return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
- getSanitizerArgs().requiresPIE();
+  getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
Index: cfe/trunk/lib/Driver/Distro.cpp
===
--- cfe/trunk/lib/Driver/Distro.cpp
+++ cfe/trunk/lib/Driver/Distro.cpp
@@ -129,6 +129,9 @@
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 


Index: cfe/trunk/include/clang/Driver/Distro.h
===
--- cfe/trunk/include/clang/Driver/Distro.h
+++ cfe/trunk/include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
martell requested review of this revision.
martell added a comment.

Thanks for the review @rnk . I addressed the comment nit you had.
@mstorsjo  I updated this to also handle thumb on arm.

When doing that I noticed there is something really strange about the existing 
macro defines. I assume they should only be defined when exceptions is enabled.
This is by default in c++ mode of with -fexceptions in c mode.
I moved the defines within a check of exceptions being enabled to address that.

Apple seem to do their own thing for watchOS by just force enabling it for that 
target only.
Some input there would help a lot.

Also if you think we should define the macros even when exceptions are disabled 
could you explain why?


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123486.
martell added a comment.
Herald added subscribers: JDevlieghere, javed.absar.

updated to handle dwarf exceptions on arm.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -2381,7 +2381,7 @@
 // ARMV6-CLOUDABI:#define __CloudABI__ 1
 // ARMV6-CLOUDABI:#define __arm__ 1
 
-// RUN: %clang -E -dM -ffreestanding -target arm-netbsd-eabi %s -o - | FileCheck -match-full-lines -check-prefix ARM-NETBSD %s
+// RUN: %clang -E -dM -ffreestanding -fexceptions -target arm-netbsd-eabi %s -o - | FileCheck -match-full-lines -check-prefix ARM-NETBSD %s
 
 // ARM-NETBSD-NOT:#define _LP64
 // ARM-NETBSD:#define __APCS_32__ 1
@@ -2645,7 +2645,7 @@
 // Thumbebv7: #define __THUMB_INTERWORK__ 1
 // Thumbebv7: #define __thumb2__ 1
 
-// RUN: %clang -E -dM -ffreestanding -target thumbv7-pc-mingw32 %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
+// RUN: %clang -E -dM -ffreestanding -fexceptions -target thumbv7-pc-mingw32 %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -673,12 +673,19 @@
 Builder.defineMacro("__BLOCKS__");
   }
 
-  if (!LangOpts.MSVCCompat && LangOpts.Exceptions)
-Builder.defineMacro("__EXCEPTIONS");
+  if 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-13 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Ping :)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39588: Distro: initial support for alpine

2017-11-08 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@rnk ping. 
Feel free to add anyone you think might be more suitable if you can't review 
this.


Repository:
  rL LLVM

https://reviews.llvm.org/D39588



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-08 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@rnk ping :)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-06 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D39673, @martell wrote:

> Long term I would like the MinGW Driver to load a different libunwind 
> depending on the exception model but that discussion might still be a little 
> off.




In https://reviews.llvm.org/D39673#917510, @mstorsjo wrote:

> I don't really see what would be necessary there; a matching unwinding 
> library should be provided in whatever C++ and compiler runtime library you 
> use, so that's mostly an issue for whoever sets up the environment to build 
> libraries in the right configurations matching it as a whole.


I mostly expect this to be useful where environment has builds all 3 versions 
of the libunwind. where the library is named differently based on the eh model.
e.g. `libunwind-sjlj.a` `libunwind-seh.a` and `libunwind-dwarf.a`
With the above exception flags the version of libunwind with the matching model 
should be automatically linked, I imagine it to be stored in a similar 
locations as the compiler-rt libs.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-06 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@mstorsjo I think this should help with issues like having to set the default 
for ARM to DWARF.
If you can set it at run time then it should be a lot easier to just set that 
in the clang wrapper scripts.

Long term I would like the MinGW Driver to load a different libunwind depending 
on the exception model but that discussion might still be a little off.
Any thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-06 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 121832.
martell added a comment.

Add command line documentation references


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp

Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
 extern "C" void bar();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -679,6 +679,8 @@
 Builder.defineMacro("__GXX_RTTI");
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
 
   if (LangOpts.Deprecated)
 Builder.defineMacro("__DEPRECATED");
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2133,7 +2133,18 @@
   Opts.Exceptions = Args.hasArg(OPT_fexceptions);
   Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
   Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
-  Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
+
+  // Handle exception personalities
+  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
+   options::OPT_fseh_exceptions,
+   options::OPT_fdwarf_exceptions);
+  if (A) {
+const Option  = A->getOption();
+Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
+Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
+Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
+  }
+
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
   Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
 
Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -64,7 +64,6 @@
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
-  bool UseSEHExceptions() const;
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -367,10 +367,6 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
-bool toolchains::MinGW::UseSEHExceptions() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-05 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.
Herald added a subscriber: aprantl.

Adds `-fseh-exceptions` and `-fdwarf-exceptions` to compliment 
`-fsjlj-exceptions`.

This makes the exception personality configurable at runtime rather then just 
compile time.

If nothing is passed to cc1 we default to `-fdwarf-exceptions`
The clang frontend will first check if the user has specified one of the above 
flags,
if not then it will check the target default and attach either 
`-fseh-exceptions` or
`-fsjlj-exceptions`. Attaching `-fdwarf-exceptions` is unnecessary because it 
is the
default and some of tests check for `-NOT: "exception"` when passing 
`-fno-exceptions`

The general rule of thumb here is `-fno-exceptions` has a higher priority then 
specifying
the exception type.

Other notable changes:

Move `__SEH__` macro definition out of Targets and into `InitPreprocessor` 
making
it dependant on `-fseh-exceptions`

Remove UseSEHExceptions from the MinGW Driver that doesn't actually do anything.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp

Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
 extern "C" void bar();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -679,6 +679,8 @@
 Builder.defineMacro("__GXX_RTTI");
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
 
   if (LangOpts.Deprecated)
 Builder.defineMacro("__DEPRECATED");
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2133,7 +2133,18 @@
   Opts.Exceptions = Args.hasArg(OPT_fexceptions);
   Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
   Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
-  Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
+
+  // Handle exception personalities
+  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
+   options::OPT_fseh_exceptions,
+   options::OPT_fdwarf_exceptions);
+  if (A) {
+const Option  = A->getOption();
+Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
+Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
+Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
+  }
+
   Opts.ExternCNoUnwind = 

[PATCH] D33620: [CodeGenCXX] do not default to dllimport storage for mingw-w64

2017-11-03 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317398: CodeGenCXX: no default dllimport storage for mingw 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D33620?vs=100523=121578#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33620

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2284,7 +2284,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
===
--- cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
+++ cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA 
-check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA 
-check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2284,7 +2284,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
===
--- cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
+++ cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s 

[PATCH] D39588: Distro: initial support for alpine

2017-11-03 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 121462.
martell edited the summary of this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D39588

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/pic.c


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -nopie -pie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // Darwin is a beautiful and unique snowflake when it comes to these flags.
 // When targeting a 32-bit darwin system, only level 2 is supported. On 64-bit
 // targets, there is simply nothing you can do, there is no PIE, there is only
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -210,7 +210,12 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
@@ -812,7 +817,7 @@
 
 bool Linux::isPIEDefault() const {
   return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
- getSanitizerArgs().requiresPIE();
+  getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -129,6 +129,9 @@
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return DistroVal == AlpineLinux;
+  }
+
   /// @}
 };
 


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie 

[PATCH] D39588: Distro: initial support for alpine

2017-11-02 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.

Add alpine linux as a distro.
We support building for musl since https://reviews.llvm.org/rL292848.
Let's add this important docker / kubernetes empowering distro.

Some bits are still missing but this is a good base.


Repository:
  rL LLVM

https://reviews.llvm.org/D39588

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -210,7 +210,12 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -129,6 +129,9 @@
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -210,7 +210,12 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -129,6 +129,9 @@
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: cfe/trunk/test/Driver/cl-options.c:524
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+

This was incorrect, it should have been `STDCXX17`.
I fixed this is rL315868


Repository:
  rL LLVM

https://reviews.llvm.org/D38123



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315865: MACHO: ld64.lld alias for the MACHO LLD target 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D38290?vs=116801=119087#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  lld/trunk/tools/lld/CMakeLists.txt
  lld/trunk/tools/lld/lld.cpp


Index: lld/trunk/tools/lld/CMakeLists.txt
===
--- lld/trunk/tools/lld/CMakeLists.txt
+++ lld/trunk/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: lld/trunk/tools/lld/lld.cpp
===
--- lld/trunk/tools/lld/lld.cpp
+++ lld/trunk/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 


Index: lld/trunk/tools/lld/CMakeLists.txt
===
--- lld/trunk/tools/lld/CMakeLists.txt
+++ lld/trunk/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: lld/trunk/tools/lld/lld.cpp
===
--- lld/trunk/tools/lld/lld.cpp
+++ lld/trunk/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Landed, @rnk I missed this message in my travels from Ireland back to Mountain 
View.
Just catching up with everything now :)


Repository:
  rL LLVM

https://reviews.llvm.org/D38123



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315864: [driver] [cl] Add/fix c++17/c++latest (authored by 
martell).

Changed prior to commit:
  https://reviews.llvm.org/D38123?vs=116154=119086#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38123

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -520,8 +520,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck 
-check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4075,7 +4075,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -520,8 +520,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4075,7 +4075,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-15 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: docs/index.rst:55
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386 ClangDWARF CFI
+Windows  i386, x86_64 ClangDWARF CFI
    

Based on your comments above I assume this supports GCC also ?
If so, replace
`Windows  i386, x86_64 ClangDWARF CFI`
with
`Windows  i386, x86_64 Clang, GCC   DWARF CFI`

This is exciting stuff Martin :)


https://reviews.llvm.org/D38819



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-10-02 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

`CODE_OWNERS.TXT` does not have a list of `driver` owners.
It does have rsmith as an owner for all things not covered by someone else so I 
added him.
Reid usually reviews driver patches I submit to clang and is on the owner list 
so I added him here initially.
I think either should be fine.
ping @rnk


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-28 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D38290#882911, @ruiu wrote:

> Is this for cross-compilation?


It is mostly for native compilation on mac but this will work for cross 
compiling also.

> If you invoke lld on macOS, it should act as ld64.

That is if the file name is `ld` or if you pass the `darwin` flavour but that 
is not how clang invokes lld.

`-fuse-ld=lld` invokes `ld.lld` which is bound to the gnu frontend only even on 
MacOS hosts.
The reason for introducing ld64 is so we can still cross compile from MacOS to 
linux targets cleanly.


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-27 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 116801.
martell added a comment.

address comment


Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  tools/clang/lib/Driver/ToolChain.cpp
  tools/lld/tools/lld/CMakeLists.txt
  tools/lld/tools/lld/lld.cpp


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if (Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if (Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

I have a patch that does a bunch of updates for testing lld correctly in clang 
and this was a part of it but I didn't want the patch to get too involved so I 
separated this out.
I have seen this issue raised on various forums such as stackoverflow here and 
figured I would just fix it for users.
https://stackoverflow.com/questions/44106329/lld-unknown-argument-arch


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-26 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.
Herald added a subscriber: mgorny.

Currently when we do `-fuse-ld=lld` for apple targets this invokes the gnu 
frontend because of the `ld.lld` alias
This creates a new alias for ld64 as `ld64.lld` to avoid this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  tools/clang/lib/Driver/ToolChain.cpp
  tools/lld/tools/lld/CMakeLists.txt
  tools/lld/tools/lld/lld.cpp


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if(Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if(Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.
This revision is now accepted and ready to land.

It seems that msvc enabled some c++17 features when in c++14 mode and they left 
them enabled because projects became dependant on them.
switching to c++17 as the default and removing the c++17 features from c++14 
mode seems like the correct thing to do here even if MS still use c++14 as 
their default.
That should be part of a different patch though because a discussion needs to 
be had on that issue.

LGTM as is.
Thanks for the contribution.


https://reviews.llvm.org/D38123



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

LGTM

we should probably set c++17 as the default over c++14 as part of this change.
given that everything seems in order for c++17 bar P0522R0 so this looks like 
the change should be good.
adding @rnk to confirm.

@daxpedda do you have commit access?




Comment at: test/Driver/cl-options.c:514
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck 
-check-prefix=CXX14 %s
 // CXX14: -std=c++14

We should probably change the default to c++17 as part of this commit.


https://reviews.llvm.org/D38123



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


[PATCH] D37727: Driver: Remove custom MinGW linker detection

2017-09-12 Thread Martell Malone via Phabricator via cfe-commits
martell closed this revision.
martell added a comment.

Landed in https://reviews.llvm.org/rL313082


Repository:
  rL LLVM

https://reviews.llvm.org/D37727



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


[PATCH] D37727: Driver: Remove custom MinGW linker detection

2017-09-12 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D37727#868284, @rnk wrote:

> Nice! IIUC, now that the gnu ld driver works on Windows we can remove this 
> logic. Thanks!


We could have removed it before the addition of the gnu ld driver, I think the 
author just missed this target and possibly others when the original patch was 
created.

Regardless, this now enables us to make standalone mingw-w64 clang toolchains 
with only llvm+clang+lld+compiler-rt without having any out of tree patches :)


Repository:
  rL LLVM

https://reviews.llvm.org/D37727



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


[PATCH] D37727: Driver: Remove custom MinGW linker detection

2017-09-12 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D37727#867751, @mstorsjo wrote:

> I do the same by adding -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld 
> -Qunused-arguments in the frontend script wrapper (a wrapper named 
> -w64-mingw32-clang that just calls clang -target -w64-mingw32 
> -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments.


I used to do this also but I didn't want to just disable warnings for unused 
arguments which left me with problems.

The following should work for that if you are happy with it being the default 
for your linux target also

  -DCLANG_DEFAULT_RTLIB=compiler-rt
  -DCLANG_DEFAULT_CXX_STDLIB=libc++
  -CLANG_DEFAULT_LINKER=lld

Though adding something like this to `Driver/MinGW.h`

  RuntimeLibType GetDefaultRuntimeLibType() const override {
return RuntimeLibType::RLT_CompilerRT;
  }
  
  CXXStdlibType
  GetCXXStdlibType(const llvm::opt::ArgList ) const override {
return ToolChain::CST_Libcxx;
  }
  
  const char *getDefaultLinker() const override {
return "lld";
  }

should work for what you want more.

> Yup, figured it out later after reading it more thorhoughly later.

We posted at roughly the same time so I missed it :)

> Actually, after testing this a bit more and looking at it, I withdraw my 
> earlier complaints - this does indeed seem to work fine with my test setup. 
> The generic `TC.GetLinkerPath()` picks up `-fuse-ld=lld` correctly and 
> converts it into `ld.lld` which should be equivalent to `lld -flavor gnu`, at 
> least in my linux cross compilation setup. And the extra `AddLibGCC()` call 
> doesn't seem harmful for the lld setup.

Great, I'll just wait for reid or peter to approve and merge then.


Repository:
  rL LLVM

https://reviews.llvm.org/D37727



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


[PATCH] D37727: Driver: Remove custom MinGW linker detection

2017-09-12 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 114801.
martell added a comment.

update tests


Repository:
  rL LLVM

https://reviews.llvm.org/D37727

Files:
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/mingw-useld.c


Index: test/Driver/mingw-useld.c
===
--- test/Driver/mingw-useld.c
+++ test/Driver/mingw-useld.c
@@ -1,19 +1,19 @@
-// RUN: %clang -### -target i686-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
-check-prefix=CHECK_LD_32 %s
-// CHECK_LD_32: ld{{(.exe)?}}"
+// RUN: %clang -### -target i686-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=platform 2>&1 | 
FileCheck -check-prefix=CHECK_LD_32 %s
+// CHECK_LD_32: "{{[^"]*}}ld{{(.exe)?}}"
 // CHECK_LD_32: "i386pe"
-// CHECK_LD_32-NOT: "-flavor" "gnu"
+// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}"
 
 // RUN: %clang -### -target i686-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_32 %s
 // CHECK_LLD_32-NOT: invalid linker name in argument
-// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_32: "i386pe"
 
 // RUN: %clang -### -target x86_64-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_64 %s
 // CHECK_LLD_64-NOT: invalid linker name in argument
-// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_64: "i386pep"
 
 // RUN: %clang -### -target arm-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_ARM %s
 // CHECK_LLD_ARM-NOT: invalid linker name in argument
-// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_ARM: "thumb2pe"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -104,14 +104,6 @@
   // handled somewhere else.
   Args.ClaimAllArgs(options::OPT_w);
 
-  StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
-  if (LinkerName.equals_lower("lld")) {
-CmdArgs.push_back("-flavor");
-CmdArgs.push_back("gnu");
-  } else if (!LinkerName.equals_lower("ld")) {
-D.Diag(diag::err_drv_unsupported_linker) << LinkerName;
-  }
-
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
@@ -241,7 +233,7 @@
 
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--end-group");
-  else if (!LinkerName.equals_lower("lld"))
+  else
 AddLibGCC(Args, CmdArgs);
 }
 
@@ -252,7 +244,7 @@
   CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
 }
   }
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data()));
+  const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 


Index: test/Driver/mingw-useld.c
===
--- test/Driver/mingw-useld.c
+++ test/Driver/mingw-useld.c
@@ -1,19 +1,19 @@
-// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s
-// CHECK_LD_32: ld{{(.exe)?}}"
+// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=platform 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s
+// CHECK_LD_32: "{{[^"]*}}ld{{(.exe)?}}"
 // CHECK_LD_32: "i386pe"
-// CHECK_LD_32-NOT: "-flavor" "gnu"
+// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}"
 
 // RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s
 // CHECK_LLD_32-NOT: invalid linker name in argument
-// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_32: "i386pe"
 
 // RUN: %clang -### -target x86_64-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s
 // CHECK_LLD_64-NOT: invalid linker name in argument
-// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_64: "i386pep"
 
 // RUN: %clang -### -target arm-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s
 // CHECK_LLD_ARM-NOT: invalid linker name in argument
-// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu"
+// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}"
 // CHECK_LLD_ARM: "thumb2pe"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ 

[PATCH] D37727: Driver: Remove custom MinGW linker detection

2017-09-12 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D37727#867627, @mstorsjo wrote:

> I'm not sure I like this direction. In my setups, a build-time default isn't 
> right since I'm using the same clang builds for both native-on-linux building 
> (with the default `ld` as linker) and cross-building targeting windows (using 
> `ldd`), and keeping the code that reads `-fuse-ld=` is essential.


The `GetLinkerPath` function in `lib/Driver/ToolChain.cpp` that I replaced this 
with already checks `-fuse-ld` and does everything we need correctly.

> I haven't followed the changes closely on how this works with the build-time 
> `CLANG_DEFAULT_LINKER`, but can't we just make the current code check this 
> define if `-fuse-ld` isn't set?

If you specifically want a toolchain that uses lld by default for MINGW but ld 
for the platform and or host you should override the `getDefaultLinker` 
function in the Mingw driver with an out of tree patch.
This is now what I do in my own builds since applying this patch. Hopefully 
when the MinGW driver becomes more stable such a patch can land in tree :)

If you are happy with all being lld or all ld you should set 
CLANG_DEFAULT_LINKER.
Note that `GetLinkerPath` also gives us the extra option to pass 
`-fuse-ld=platform` to use the platform default instead of the compile time 
default.




Comment at: lib/Driver/ToolChains/MinGW.cpp:107
 
-  StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "lld");
-  if (LinkerName.equals_lower("lld")) {

mstorsjo wrote:
> This diff isn't based on the current master version, where this defaults to 
> `ld`
Yeah the line was supposed to read
`StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");`
It was applied on top a commit for clang that changed ld -> lld here.
The reason I want to merge this is so that I can stop doing that :)
For the review because I am removing the line it does not matter much, I will 
update the diff to remove the extra `l` in the next revision.




Comment at: lib/Driver/ToolChains/MinGW.cpp:236
 CmdArgs.push_back("--end-group");
-  else if (!LinkerName.equals_lower("lld"))
+  else
 AddLibGCC(Args, CmdArgs);

mstorsjo wrote:
> So if you do a clang build that defaults to `lld`, this should suddenly be 
> included?
The previous check was if not lld so it would include it if it was ld or 
anything else.
The MINGW lld driver does not complain about this, the behaviour should be the 
same for both.


Repository:
  rL LLVM

https://reviews.llvm.org/D37727



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


[PATCH] D37726: clang: alias -static-{libstdc++, libgcc} for LLVM variants

2017-09-11 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.

Alias `-static-compiler-rt` and `static-libc++` to their gcc counterparts.
Currently invoking `-static-libgcc` or `-static-libstdc++` will ensure only use 
of static libs.
In future if we want to do more accurate handling with better behaviour with 
the linker we can remove the alias and pass a custom flag.
For now this would be a great alias for sanity.


Repository:
  rL LLVM

https://reviews.llvm.org/D37726

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2270,7 +2270,9 @@
 def specs_EQ : Joined<["-", "--"], "specs=">;
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
+def static_compiler_rt : Flag<["-"], "static-compiler-rt">, 
Alias;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">, Alias;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2270,7 +2270,9 @@
 def specs_EQ : Joined<["-", "--"], "specs=">;
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
 def static_libgcc : Flag<["-"], "static-libgcc">;
+def static_compiler_rt : Flag<["-"], "static-compiler-rt">, Alias;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
+def static_libcxx : Flag<["-"], "static-libc++">, Alias;
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37530: [MinGW] Don't link -lmsvcrt if a different msvcrt version is to be linked

2017-09-11 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.

LGMT


https://reviews.llvm.org/D37530



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


[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target

2017-08-09 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36364



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


[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target

2017-08-06 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:130
+  case llvm::Triple::arm:
+  case llvm::Triple::thumb:
 CmdArgs.push_back("thumb2pe");

I believe this was left incase someone wanted to do windows ce in future.
Can you add a todo like in CrossWindows.cpp in this case
`// FIXME: this is incorrect for WinCE`
or if we don't care about WinCE anymore just remove the TODO from CrossWindows?


https://reviews.llvm.org/D36364



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


[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target

2017-08-06 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:129
+  else if (TC.getArch() == llvm::Triple::aarch64)
+CmdArgs.push_back("arm64pe");
+  else

mstorsjo wrote:
> martell wrote:
> > I believe the reason I used thumb2pe for the arm triple is because MS gave 
> > us a watered down thumb environment.
> > If I remember correctly there was also an armce environment in binutils 
> > called thumbpe because it was thumb 1 mode.
> > Anyway, I assume aarch64 on windows is a fully fledged arm64 environment 
> > that doesn't use thumb mode over arm64?
> > I know we don't have any real sdk for this but are you able to tell from 
> > link.exe martin?
> > On arm the branch for a dll call would always set the bit for thumb mode in 
> > the instruction.
> > Although when I think about it arm64pe is probably the most suitable name 
> > anyway because we already use thumb2pe
> > 
> There's no thumb mode at all in 64 bit mode (yet at least), so naming it 
> thumb* wouldn't make sense. Modelling the previous name after the old thumbpe 
> makes sense though.
Great, thanks. Just wanted to clarify because we never had a discussion about 
the naming.
LGTM


https://reviews.llvm.org/D36364



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


[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target

2017-08-06 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: lib/Driver/ToolChains/MinGW.cpp:129
+  else if (TC.getArch() == llvm::Triple::aarch64)
+CmdArgs.push_back("arm64pe");
+  else

I believe the reason I used thumb2pe for the arm triple is because MS gave us a 
watered down thumb environment.
If I remember correctly there was also an armce environment in binutils called 
thumbpe because it was thumb 1 mode.
Anyway, I assume aarch64 on windows is a fully fledged arm64 environment that 
doesn't use thumb mode over arm64?
I know we don't have any real sdk for this but are you able to tell from 
link.exe martin?
On arm the branch for a dll call would always set the bit for thumb mode in the 
instruction.
Although when I think about it arm64pe is probably the most suitable name 
anyway because we already use thumb2pe



https://reviews.llvm.org/D36364



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


[PATCH] D34873: Fix miscompiled 32bit binaries by mingw

2017-08-04 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@rnk isn't this related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78936
Assuming this is in fact a gcc bug this will most likely cause a regression 
with the standalone clang mingw toolchains we are on the verge of having.
This is of course assuming clang does not have the same regression gcc does.


https://reviews.llvm.org/D34873



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: examples/clang-interpreter/Manager.cpp:18
+#define NOMINMAX
+#include 
+#endif

windows.h with lower case `w` to not break mingw


https://reviews.llvm.org/D35103



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Just 2 small nits.




Comment at: examples/clang-interpreter/main.cpp:165
+  llvm::errs() << "'main' function not found in module.\n";
+  return 255;
+}

255 -> Res ?



Comment at: examples/clang-interpreter/main.cpp:173
+  llvm::errs() << "unable to make execution engine: " << Error << "\n";
+  return 255;
+}

255 -> Res


https://reviews.llvm.org/D35103



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


[PATCH] D34606: [libcxx] Link MinGW libs for shared build

2017-06-29 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Not quite sure how this achieves anything different from what is already in 
`cmake/config-ix.cmake` ?
https://reviews.llvm.org/D33638 addresses the remaining changes needed to build 
for windows shared and static in one build.


Repository:
  rL LLVM

https://reviews.llvm.org/D34606



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

> ! In https://reviews.llvm.org/D33852#772290, @davide wrote:
>  This assumption is not quite right. Also GCC, when targeting Linux, provides 
> a `-fms-extensions` flag.
>  There's a bunch of software out there that unfortunately has to target ELF 
> and build with `-fms-extensions` on, e.g. PS4.

Seems like bad practice but on a second look that is does appear that PS4 and 
CUDA both use `-fms-extensions` and rely on it for some things. argh
CUDA does have a note to move off this in future.
Thanks for clarifying davide

This patch does LGTM minus the nit above.
Adding `selectany` spelling to `-fdeclspec` as well as `-fms-extensions` should 
cover all use cases.
The MachO issue would have been present before `rL300562` so I don't think that 
should have to be fixed here.
It could be covered in a follow up differential as this fixes a regression on 
my part.




Comment at: test/Sema/attr-selectany.c:3
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fms-extensions %s
 

Based on the current changes you can change `-fms-extensions` to `-fdeclspec`
The `-fms-extensions` coverage is covered in `attr-selectany.cpp` below


https://reviews.llvm.org/D33852



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-03 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

@Prazek it wasn't disabled by mistake.
This was a MS extension and it appeared as though the test case should have 
been for windows.
I updated it and made the extension available to windows only. (MSVC, Cygwin, 
Mingw etc)
It didn't expect anyone would want a MS extension for a linux target.

I don't think it is unreasonable to have support for this though. 
Adding @rnk here as he may have some comments.


https://reviews.llvm.org/D33852



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


[PATCH] D33620: [CodeGenCXX] do not default to dllimport storage for mingw-w64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.

GNU frontends don't have options like `/MT`, `/MD` etc so it makes little sense.
This fixes a few link error regressions with libc++ and libc++abi


Repository:
  rL LLVM

https://reviews.llvm.org/D33620

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/runtime-dllstorage.cpp


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA 
-check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA 
-check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2169,7 +2169,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2169,7 +2169,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  

[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

> ! In https://reviews.llvm.org/D33082#765898, @EricWF wrote:
>  I removed the section you're referring to because it's unneeded. 
> `<__locale>` does the exact same `#include` dance. and `` includes 
> `<__locale>`.
>  It should not have an affect on functionality.

It that case it just ignore my previous comment. LGTM


https://reviews.llvm.org/D33082



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

LGTM but I can't speak for the area where you added `#include ` and 
killed off the `_NEWLIB_VERSION` check
Seems in order based on 
https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
Maybe make a note of the minimum newlib version supported somewhere?

Others may have more specific thoughts on the diff.


https://reviews.llvm.org/D33082



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-25 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

> ! In https://reviews.llvm.org/D33082#764617, @EricWF wrote:
>  Defining `_GNU_SOURCE` during the library build isn't enough, it's also has 
> to be defined when people are using the headers,
>  and in that case we must depend on the compiler to pre-define it. Is it 
> important that MinGW not define `_GNU_SOURCE` by default?

I'm not sure why this isn't the default, it could be some backwards 
compatability with mingw.org.
I will ask kai the author and find out.

> Also do you know why `asprintf` is declared by mingw-w64 but `vasprintf` 
> isn't? At minimum I think we still need to declare `vasprintf` in the
>  headers because we can't count on `_GNU_SOURCE` being defined before 
> `` is first included, but we should be able to omit
>  the definition.

I believe it is in stdio.h but behind the guard `__USE_MINGW_ANSI_STDIO`
You are currently picking up is msvc compatable asprintf and not gnu.
Defining this will give you the gnu versions of both and also the GNU printf 
format specifiers.

> Are you suggesting that libc++ should stop declaring/defining these 
> functions, at least publically?

We could in the future run into real world problems with projects that work 
with libstdc++ fine but will have problems with libc++ if a project implements 
its own version but
I wouldn't be too concerned about this right now because when that becomes a 
problem it will prompt people to get these into mingw-w64 upstream.


https://reviews.llvm.org/D33082



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

I want to give some context here to dispel the confusion of what is and isn't 
win32 api specific.

First lets take `vasprintf` and `asprintf ` which are not implemented in msvcrt.
In mingw-w64 we would just have posix implementations of both.
They are hidden behind the guard `_GNU_SOURCE`, we don't need to declare them 
in `include/stdio.h` in libcxx but
By default gcc doesn't pass this flag for the mingw target so we should add it 
in cmake within libc++.
We should be able to guard mingw to stop it from picking up the implementations 
in `windows/support.cpp`

Next example

Example `mbsnrtowcs` and `wcsnrtombs` above
This is technically a win32api specific implementation in msvc. The mingw-w64 
implementation or lack there of would rely on the MSVC implementation.
This is why a custom implementation lives in libc++ in `support.cpp` that is 
posix compliant.
Unfortunately a posix implementation might not be accepted upstream into 
mingw-w64 because they need to maintain compatibility with msvc, even with some 
bugs eek.
It generally comes down to if a bunch of projects are using it already and we 
should not disrupt them relying on msvc implementations/bugs.
This is probably not the case for these two functions but there are many others 
already in the library that follow this guideline.

A good read of this specific bug is here.
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130325/077071.html

@smeenai suggestion of `_LIBCPP_MSVCRT_LIKE` makes a lot of sense here because 
mingw-w64 is only partially posixy, this leaves room for future possible 
targets like midipix which uses musl libc to ignore this section of code where 
mingw and msvc opt in.


https://reviews.llvm.org/D33082



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

It won't let me revert the automatically updated diff to the previous one 
because I am not the author.
@faisalv are you able todo this and Sorry for the confusion.


Repository:
  rL LLVM

https://reviews.llvm.org/D15005



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In case anyone comes here looking for https://reviews.llvm.org/rL300555 that 
should be https://reviews.llvm.org/D15006 no https://reviews.llvm.org/D15005.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D15005



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


[PATCH] D15006: Driver: Better detection of mingw-gcc

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Committed as https://reviews.llvm.org/rL300555


Repository:
  rL LLVM

https://reviews.llvm.org/D15006



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300555: Driver: Better detection of mingw-gcc (authored by 
martell).

Changed prior to commit:
  https://reviews.llvm.org/D15005?vs=41206=95568#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D15005

Files:
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
  cfe/trunk/lib/Driver/ToolChains/MinGW.h


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.h
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.h
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15006: Driver: Better detection of mingw-gcc

2017-04-14 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

To clarify the most import part about actually being able to test this is the 
being able to modify the PATH variable for windows and unix hosts in the test 
case.
The program prefix is less of a problem because I can double down with the same 
empty file one with .exe and one without.
Just thought that I would note it incase someone has ran into this already.


Repository:
  rL LLVM

https://reviews.llvm.org/D15006



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


[PATCH] D15006: Driver: Better detection of mingw-gcc

2017-04-14 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 95292.
martell edited the summary of this revision.
martell added a reviewer: yaron.keren.
martell added a subscriber: yaron.keren.
martell added a comment.

After the revert I left this patch go to pick up some other patch work.
Seen as we are not anywhere near the next release this seem like a good time to 
pick it up again.
Also got a reminder when yaron resigned

Updated to master.
@ismail can you confirm this update works for your custom opensuse setup on 
master.
@yaron.keren I can't do a non flaky test case for this it seems because on 
windows we need .exe extension and not on unix.
Also we need the test case to be able to set the PATH variable to be able to 
test this fully.

I would like to consider this as working because it passes all the existing 
Driver testcases in `test/Driver/mingw.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D15006

Files:
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();