Fix MacOS build
authorMehdi Amini <aminim@google.com>
Mon, 1 Apr 2019 17:17:45 +0000 (10:17 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 1 Apr 2019 18:00:30 +0000 (11:00 -0700)
    This is making up for some differences in standard library and linker flags.
    It also get rid of the requirement to build with RTTI.

--

PiperOrigin-RevId: 241348845

mlir/CMakeLists.txt
mlir/lib/Transforms/LoopTiling.cpp
mlir/tools/mlir-cpu-runner/CMakeLists.txt
mlir/tools/mlir-opt/CMakeLists.txt
mlir/tools/mlir-translate/CMakeLists.txt

index c0d1029..882c249 100644 (file)
@@ -20,11 +20,18 @@ endfunction()
 # TODO: This is to handle the current static registration, but should be
 # factored out a bit.
 function(whole_archive_link target)
-  set(link_flags "-Llib -Wl,--whole-archive,")
-  FOREACH(LIB ${ARGN})
-    string(CONCAT link_flags ${link_flags} "-l${LIB},")
-  ENDFOREACH(LIB)
-  string(CONCAT link_flags ${link_flags} "--no-whole-archive")
+  if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+    set(link_flags "-Llib -Wl,-all_load ")
+    FOREACH(LIB ${ARGN})
+      string(CONCAT link_flags ${link_flags} "-l${LIB} ")
+    ENDFOREACH(LIB)
+  else()
+    set(link_flags "-Llib -Wl,--whole-archive,")
+    FOREACH(LIB ${ARGN})
+      string(CONCAT link_flags ${link_flags} "-l${LIB},")
+    ENDFOREACH(LIB)
+    string(CONCAT link_flags ${link_flags} "--no-whole-archive")
+  endif()
   set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
 endfunction(whole_archive_link)
 
index f7fef1a..d262a5d 100644 (file)
@@ -368,7 +368,8 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
       (*tileSizes)[i] = tSize;
     else
       // Set last tile size to cover the balance.
-      (*tileSizes)[i] = std::max(1UL, excessFactor / cumulProductOfTileSizes);
+      (*tileSizes)[i] = std::max(
+          1U, static_cast<unsigned>(excessFactor / cumulProductOfTileSizes));
     cumulProductOfTileSizes *= (*tileSizes)[i];
   }
   if (avoidMaxMinBounds)
index af448d1..1c59ae5 100644 (file)
@@ -13,6 +13,6 @@ set(LIBS
 add_executable(mlir-cpu-runner
   mlir-cpu-runner.cpp
 )
-
+llvm_update_compile_flags(mlir-cpu-runner)
 whole_archive_link(mlir-cpu-runner MLIRLLVMIR MLIRStandardOps MLIRTargetLLVMIR MLIRTransforms MLIRTranslation)
 target_link_libraries(mlir-cpu-runner MLIRIR ${LIBS})
index 8cb8551..def266d 100644 (file)
@@ -13,6 +13,6 @@ set(LIBS
 add_executable(mlir-opt
   mlir-opt.cpp
 )
-
+llvm_update_compile_flags(mlir-opt)
 whole_archive_link(mlir-opt ${LIBS})
 target_link_libraries(mlir-opt MLIRIR ${LIBS} LLVMSupport)
index 74e1897..330c9ad 100644 (file)
@@ -14,6 +14,6 @@ set(LIBS
 add_executable(mlir-translate
   mlir-translate.cpp
 )
-
+llvm_update_compile_flags(mlir-translate)
 whole_archive_link(mlir-translate ${LIBS})
 target_link_libraries(mlir-translate MLIRIR ${LIBS} LLVMSupport)