From faa0abea3e21c531b86279a13505c99d319d0277 Mon Sep 17 00:00:00 2001 From: youben11 Date: Tue, 18 Jan 2022 13:33:36 +0100 Subject: [PATCH] fix: use appropriate cmd for dynamic lib generation macos and linux require a different cmd --- compiler/lib/Support/CompilerEngine.cpp | 7 ++++++- .../test_compiler_file_output/test_compiler_file_output.py | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/lib/Support/CompilerEngine.cpp b/compiler/lib/Support/CompilerEngine.cpp index 69bfbbad3..342253b06 100644 --- a/compiler/lib/Support/CompilerEngine.cpp +++ b/compiler/lib/Support/CompilerEngine.cpp @@ -408,11 +408,16 @@ const std::string CompilerEngine::Library::OBJECT_EXT = ".o"; const std::string CompilerEngine::Library::CLIENT_PARAMETERS_EXT = ".concrete.params.json"; const std::string CompilerEngine::Library::LINKER = "ld"; +#ifdef __APPLE__ +const std::string CompilerEngine::Library::LINKER_SHARED_OPT = " -dylib -o "; +const std::string CompilerEngine::Library::DOT_SHARED_LIB_EXT = ".dylib"; +#else // Linux const std::string CompilerEngine::Library::LINKER_SHARED_OPT = " --shared -o "; +const std::string CompilerEngine::Library::DOT_SHARED_LIB_EXT = ".so"; +#endif const std::string CompilerEngine::Library::AR = "ar"; const std::string CompilerEngine::Library::AR_STATIC_OPT = " rcs "; const std::string CompilerEngine::Library::DOT_STATIC_LIB_EXT = ".a"; -const std::string CompilerEngine::Library::DOT_SHARED_LIB_EXT = ".so"; void CompilerEngine::Library::addExtraObjectFilePath(std::string path) { objectsPath.push_back(path); diff --git a/compiler/tests/python/test_compiler_file_output/test_compiler_file_output.py b/compiler/tests/python/test_compiler_file_output/test_compiler_file_output.py index c0d55868e..8e5dc10ca 100644 --- a/compiler/tests/python/test_compiler_file_output/test_compiler_file_output.py +++ b/compiler/tests/python/test_compiler_file_output/test_compiler_file_output.py @@ -1,5 +1,6 @@ import os import subprocess +import sys import pytest @@ -17,7 +18,8 @@ SOURCE_C_2 = f'{TEST_PATH}/main_return_0.c' OUTPUT = f'{TEST_PATH}/output.mlir' LIB = f'{TEST_PATH}/outlib' LIB_STATIC = LIB + '.a' -LIB_DYNAMIC = LIB + '.so' +DYNAMIC_LIB_EXT = '.dylib' if sys.platform == 'darwin' else '.so' +LIB_DYNAMIC = LIB + DYNAMIC_LIB_EXT LIBS = (LIB_STATIC, LIB_DYNAMIC) assert_exists(SOURCE_1, SOURCE_2, SOURCE_C_1, SOURCE_C_2)