fix: use appropriate cmd for dynamic lib generation

macos and linux require a different cmd
This commit is contained in:
youben11
2022-01-18 13:33:36 +01:00
committed by Ayoub Benaissa
parent b8cfaeb3f4
commit faa0abea3e
2 changed files with 9 additions and 2 deletions

View File

@@ -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);

View File

@@ -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)