[PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well

2018-02-18 Thread Rink via Phabricator via cfe-commits
zhmu created this revision.
zhmu added a reviewer: jroelofs.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: EricWF.

I'm trying to build libunwind as prerequisite for libcxx/libcxxabi. The target 
doesn't yet support userland threads, so I set LIBUNWIND_ENABLE_THREADS to 
'OFF' in CMake (also,  LLVM_ENABLE_LIBCXX is set to 'on'). This fails to build:

  /home/rink/github/ananas/toolchain/x86_64-ananas-elf-clang 
--target=x86_64-ananas-elf --sysroot=/tmp/ananas-build  
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/rink/github/ananas/external/llvm/projects/libunwind/include 
-I/home/rink/github/ananas/external/llvm/projects/libcxx/include -stdlib=libc++ 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics -std=c++11 
-g -fPIC   -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion 
-Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wno-unused-function -Wshadow 
-Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 
-Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings 
-Wundef -Wno-error -pedantic -D_DEBUG -D_LIBUNWIND_IS_NATIVE_ONLY 
-D_LIBUNWIND_HAS_NO_THREADS -fno-exceptions -funwind-tables   -stdlib=libc++ 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics -std=c++11 
-fstrict-aliasing -nostdinc++ -fno-rtti -MD -MT 
src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -MF 
src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o.d -o 
src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -c 
/home/rink/github/ananas/external/llvm/projects/libunwind/src/libunwind.cpp
  In file included from 
/home/rink/github/ananas/external/llvm/projects/libunwind/src/libunwind.cpp:13:
  In file included from 
/home/rink/github/ananas/external/llvm/projects/libunwind/include/libunwind.h:19:
  In file included from 
/home/rink/github/ananas/external/llvm/projects/libcxx/include/stdint.h:102:
  
/home/rink/github/ananas/external/llvm/projects/libcxx/include/__config:1056:4: 
error: "No thread API"
  #  error "No thread API"
 ^
  1 error generated.

As the 'do not use threads' flag isn't passed to libcxx. I've attached a patch 
to remedy this - I hope it is the correct place to do so.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D43442

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -296,6 +296,10 @@
 # Threading-support
 if (NOT LIBUNWIND_ENABLE_THREADS)
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
+  if(LLVM_ENABLE_LIBCXX)
+# Ensure libcxx doesn't try to use threads either
+list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBCPP_HAS_NO_THREADS)
+  endif()
 endif()
 
 # ARM WMMX register support


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -296,6 +296,10 @@
 # Threading-support
 if (NOT LIBUNWIND_ENABLE_THREADS)
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
+  if(LLVM_ENABLE_LIBCXX)
+# Ensure libcxx doesn't try to use threads either
+list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBCPP_HAS_NO_THREADS)
+  endif()
 endif()
 
 # ARM WMMX register support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well

2018-02-18 Thread Rink via Phabricator via cfe-commits
zhmu added a comment.

I've added jroelofs to the reviewer list as we spoke about this in #llvm quite 
some time ago.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D43442



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


[PATCH] D43443: libcxxabi: when building without threads, pass this to libcxx as well

2018-02-18 Thread Rink via Phabricator via cfe-commits
zhmu created this revision.
zhmu added a reviewer: jroelofs.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: EricWF.

I'm trying to build libcxxabi as prerequisite for libcxx. The target doesn't 
yet support userland threads, so I set LIBCXXABI_ENABLE_THREADS to 'OFF' in 
CMake (also, LLVM_ENABLE_LIBCXX is set to 'on' andLIBCXXABI_USE_LLVM_UNWINDER 
is 'yes'). This fails to build:

  /home/rink/github/ananas/toolchain/x86_64-ananas-elf-clang 
--target=x86_64-ananas-elf --sysroot=/tmp/ananas-build  
-D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCXXABI_BUILDING_LIBRARY 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/rink/github/ananas/external/llvm/projects/libcxxabi/include 
-I/home/rink/github/ananas/external/llvm/projects/libcxx/include 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics  -fPIC   
-nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion 
-Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow 
-Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 
-Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings 
-Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -funwind-tables -D_DEBUG 
-std=c++11 -MD -MT src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o -MF 
src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o.d -o 
src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o -c 
/home/rink/github/ananas/external/llvm/projects/libcxxabi/src/cxa_demangle.cpp
  In file included from 
/home/rink/github/ananas/external/llvm/projects/libcxxabi/src/cxa_demangle.cpp:20:
  In file included from 
/home/rink/github/ananas/external/llvm/projects/libcxx/include/vector:264:
  
/home/rink/github/ananas/external/llvm/projects/libcxx/include/__config:1056:4: 
error: "No thread API"
  #  error "No thread API"

My patch is  similar to https://reviews.llvm.org/D43442: emit a define so that 
libcxx works when included.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D43443

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -333,6 +333,8 @@
 " is also set to ON.")
   endif()
   add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
+  # propgate no threads to libcxx, which uses a different flag
+  add_definitions(-D_LIBCPP_HAS_NO_THREADS)
 endif()
 
 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -333,6 +333,8 @@
 " is also set to ON.")
   endif()
   add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
+  # propgate no threads to libcxx, which uses a different flag
+  add_definitions(-D_LIBCPP_HAS_NO_THREADS)
 endif()
 
 if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41500: ananas: Add shared library support

2017-12-21 Thread Rink via Phabricator via cfe-commits
zhmu created this revision.
zhmu added a reviewer: ed.
Herald added a subscriber: cfe-commits.

The Ananas Operating System (https://github.com/zhmu/ananas) has shared library 
support as of commit 57739c0b6ece56dd4872aedf30264ed4b9412c77.

This change adds the necessary settings to clang so that shared executables and 
libraries can be build correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D41500

Files:
  lib/Driver/ToolChains/Ananas.cpp
  test/Driver/ananas.c


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s 
\
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie)) {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
+} else {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+}
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -98,7 +115,10 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
+else
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
   }
 


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s \
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 CmdArgs.push_back(Args.MakeArgString(ToolChain

[PATCH] D41500: ananas: Add shared library support

2017-12-29 Thread Rink via Phabricator via cfe-commits
zhmu added a comment.

@ed I tried to keep things as much in line as the other 
::linker::Construct() functions do. Do you wish to stray from that path?

I actually prefer to keep it like this as it's quite readable already, but YMMV 
of course :-)


Repository:
  rC Clang

https://reviews.llvm.org/D41500



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


[PATCH] D124729: [Driver][Ananas] -r: imply -nostdlib like GCC

2022-05-01 Thread Rink via Phabricator via cfe-commits
zhmu added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124729

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