[PATCH] EXPORTED_SYMBOL_FILE using mingw and cmake

Chris Bieneman beanz at apple.com
Wed Oct 29 10:06:41 PDT 2014


Owen,

I didn't mean to imply he should circumvent me. I was just trying to re-iterate, that this patch isn't exactly my area of expertise.

Johannes,

I get that you put in updates to the patch, but your updates (which were attached earlier) don't actually address my original feedback. This may just be a miscommunication, so let me clarify. Your changes are inside a conditional block that is essentially "if (not darwin and not LLVM_HAVE_LINK_VERSION_SCRIPT)". While in practice it may be equivalent, it is not actually the same as "if (Windows)".

That is why I think this patch needs to be updated to something more similar to:

```
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 81b21fb..9ebeca4 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -85,17 +85,20 @@ function(add_llvm_symbol_exports target_name export_file)
  else()
    set(native_export_file "${target_name}.def")

-    set(CAT "type")
-    if(CYGWIN)
-      set(CAT "cat")
+    set(CAT "cat")
+    set(export_file_nativeslashes ${export_file}) 
+    if(WIN32 AND NOT CYGWIN)
+      set(CAT "type")
+      # Convert ${export_file} to native format (backslashes) for "type"
+      # Does not use file(TO_NATIVE_PATH) as it doesn't create a native
+      # path but a build-system specific format (see CMake bug
+      # http://public.kitware.com/Bug/print_bug_page.php?bug_id=5939 )
+      string(REPLACE / \\ export_file_nativeslashes ${export_file})
    endif()

-    # Using ${export_file} in add_custom_command directly confuses cmd.exe.
-    file(TO_NATIVE_PATH ${export_file} export_file_backslashes)
-
    add_custom_command(OUTPUT ${native_export_file}
      COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > ${native_export_file}
-      COMMAND ${CAT} ${export_file_backslashes} >> ${native_export_file}
+      COMMAND ${CAT} ${export_file_nativeslashes} >> ${native_export_file}
      DEPENDS ${export_file}
      VERBATIM
      COMMENT "Creating export file for ${target_name}")
```

This patch doesn't merely make 'cat' the default instead of 'type', it actually handles the only case you should ever use 'type', which is if you are on Win32 and not using Cygwin. Do you understand the distinction I'm trying to make?

http://reviews.llvm.org/D5476






More information about the llvm-commits mailing list