[PATCH] D68430: Don't use object libraries with Xcode

2019-10-04 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose closed this revision.
jordan_rose added a comment.

Committed as rC373769 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-04 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

That's fine. That said, there are things that just can't be done, or don't work 
well, in the Xcode and Visual Studio generators, so we have precedent for 
disabling functionality based on those generators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-04 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose updated this revision to Diff 223250.
jordan_rose added a comment.

Okay, having Xcode force-load the static libraries doesn't seem bad at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/clang-shlib/CMakeLists.txt


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -6,7 +6,13 @@
 get_property(clang_libs GLOBAL PROPERTY CLANG_STATIC_LIBS)
 
 foreach (lib ${clang_libs})
-  list(APPEND _OBJECTS $)
+  if(XCODE)
+# Xcode doesn't support object libraries, so we have to trick it into
+# linking the static libraries instead.
+list(APPEND _DEPS "-force_load" ${lib})
+  else()
+list(APPEND _OBJECTS $)
+  endif()
   list(APPEND _DEPS $)
   list(APPEND _DEPS $)
 endforeach ()
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,9 +86,13 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()


Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -6,7 +6,13 @@
 get_property(clang_libs GLOBAL PROPERTY CLANG_STATIC_LIBS)
 
 foreach (lib ${clang_libs})
-  list(APPEND _OBJECTS $)
+  if(XCODE)
+# Xcode doesn't support object libraries, so we have to trick it into
+# linking the static libraries instead.
+list(APPEND _DEPS "-force_load" ${lib})
+  else()
+list(APPEND _OBJECTS $)
+  endif()
   list(APPEND _DEPS $)
   list(APPEND _DEPS $)
 endforeach ()
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,9 +86,13 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-04 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

In D68430#1693965 , @beanz wrote:

> clang_cpp can't link the libraries "normally" because it has no unresolved 
> symbols to force the contents of the libraries to link. I don't like it, but 
> I think the best option is to disable clang_cpp under Xcode. You can add `AND 
> XCODE` to the `if` on line 2 of clang/tools/clang-shlib/CMakeLists.txt, and 
> that should do the trick.


I do think it's okay to just not support that target for Xcode, but another 
option would be to add `-all_load` to the linker line, the ld64 option that 
just unconditionally includes all archives. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D68430#1693964 , @jordan_rose wrote:

> I'm not quite sure //what// it's doing. The executable targets end up trying 
> to link against the static libraries anyway, which of course haven't been 
> built. It's possible that this is because the LIBTYPE is both STATIC and 
> OBJECT and if it were just OBJECT we might be better off, but I'm not sure if 
> Xcode's IDE features will be happy with a target that doesn't actually 
> produce a library. I can try it if you want, though.


I don't think that is necessary, it sounds like we just need to disable this 
functionality if Xcode is the build tool. That is unfortunate, but Xcode's 
build system is problematic to work with.

> (I did look at CMake's Xcode generator logic for OBJECT targets and it looks 
> completely bonkers to me, as if it's still building the static library but 
> then removing it to make sure it's not depended on or something. Even if it 
> builds cleanly I don't trust it to do dependency analysis correctly.)

Fair. Unfortunately Xcode's build dependencies aren't as expressive as other 
build systems, which causes some unfortunate limitations on what it can do.

> 
> 
>> This has the side-effect of making `libclang_cpp` effectively empty when you 
>> build with Xcode.
> 
> I can remove that target if you want, or have it link the libraries normally.

clang_cpp can't link the libraries "normally" because it has no unresolved 
symbols to force the contents of the libraries to link. I don't like it, but I 
think the best option is to disable clang_cpp under Xcode. You can add `AND 
XCODE` to the `if` on line 2 of clang/tools/clang-shlib/CMakeLists.txt, and 
that should do the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

I'm not quite sure //what// it's doing. The executable targets end up trying to 
link against the static libraries anyway, which of course haven't been built. 
It's possible that this is because the LIBTYPE is both STATIC and OBJECT and if 
it were just OBJECT we might be better off, but I'm not sure if Xcode's IDE 
features will be happy with a target that doesn't actually produce a library. I 
can try it if you want, though.

(I did look at CMake's Xcode generator logic for OBJECT targets and it looks 
completely bonkers to me, as if it's still building the static library but then 
removing it to make sure it's not depended on or something. Even if it builds 
cleanly I don't trust it to do dependency analysis correctly.)

> This has the side-effect of making `libclang_cpp` effectively empty when you 
> build with Xcode.

I can remove that target if you want, or have it link the libraries normally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

This has the side-effect of making `libclang_cpp` effectively empty when you 
build with Xcode.

What exactly does Xcode do with `OBJECT` libraries?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68430



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


[PATCH] D68430: Don't use object libraries with Xcode

2019-10-03 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose created this revision.
jordan_rose added a reviewer: beanz.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Undoes some of the effects of D61909  when 
using the Xcode CMake generator—it doesn't handle object libraries correctly at 
all. Attempts to still honor `BUILD_SHARED_LIBS` for Xcode, but I didn't 
actually test it. Should have no effect on non-Xcode generators.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68430

Files:
  clang/cmake/modules/AddClang.cmake


Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,11 +86,15 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 


Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -86,11 +86,15 @@
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
 # so we need to handle it here.
 if(BUILD_SHARED_LIBS)
-  set(LIBTYPE SHARED OBJECT)
+  set(LIBTYPE SHARED)
 else()
-  set(LIBTYPE STATIC OBJECT)
+  set(LIBTYPE STATIC)
+endif()
+if(NOT XCODE)
+  # The Xcode generator doesn't handle object libraries correctly.
+  list(APPEND LIBTYPE OBJECT)
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits