diff --git a/CMakeLists.txt b/CMakeLists.txt index e07b0a0e70b..eac804dac71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,8 +254,9 @@ if(NOT WIN32 AND NOT CYGWIN) # weak symbol Y means the weak symbol cannot be overridden at runtime. This was likely caused by # different translation units being compiled with different visibility settings." # See LLVM's cmake/modules/HandleLLVMOptions.cmake. + # For plugins, we shouldn't apply this flag because it hides the inline methods of e.g. Visitor. check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) - if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG}) + if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} AND NOT LDC_ENABLE_PLUGINS) append("-fvisibility-inlines-hidden" LDC_CXXFLAGS) endif() endif() @@ -683,10 +684,13 @@ if(LDC_ENABLE_PLUGINS) if(LINKER_ACCEPTS_EXPORT_DYNAMIC_FLAG) set(LDC_LINKERFLAG_LIST "${LDC_LINKERFLAG_LIST};-Wl,--export-dynamic") + else() + message(WARNING "Linker does not accept --export-dynamic, user plugins may give missing symbol errors upon load") endif() endif() endif() message(STATUS "-- Building LDC with plugin support (LDC_ENABLE_PLUGINS): ${LDC_ENABLE_PLUGINS}") +message(STATUS "-- Linking LDC with flags: ${ALTERNATIVE_MALLOC_O};${LDC_LINKERFLAG_LIST}") build_d_executable( "${LDC_EXE}" diff --git a/cmake/Modules/BuildDExecutable.cmake b/cmake/Modules/BuildDExecutable.cmake index 32101dafd5c..4440fe678f9 100644 --- a/cmake/Modules/BuildDExecutable.cmake +++ b/cmake/Modules/BuildDExecutable.cmake @@ -40,7 +40,8 @@ function(build_d_executable target_name output_exe d_src_files compiler_args lin # Compile all D modules to a single object. set(object_file ${PROJECT_BINARY_DIR}/obj/${target_name}${CMAKE_CXX_OUTPUT_EXTENSION}) # Default to -linkonce-templates with LDMD host compiler, to speed-up optimization. - if("${D_COMPILER_ID}" STREQUAL "LDMD") + # Note: for plugin support we need the symbols to be global, don't use -linkonce-templates. + if("${D_COMPILER_ID}" STREQUAL "LDMD" AND NOT LDC_ENABLE_PLUGINS) set(dflags -linkonce-templates ${dflags}) endif() add_custom_command( @@ -105,7 +106,7 @@ function(build_d_executable target_name output_exe d_src_files compiler_args lin add_custom_command( OUTPUT ${output_exe} - COMMAND ${D_COMPILER} ${dflags} -of${output_exe} ${objects_args} ${dep_libs} ${translated_linker_args} + COMMAND ${D_COMPILER} ${dflags} -of${output_exe} ${objects_args} ${dep_libs} ${translated_linker_args} -fvisibility=public WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} DEPENDS ${target_name}_d_objects ${object_files} ${link_deps} ) diff --git a/tests/plugins/lit.local.cfg b/tests/plugins/lit.local.cfg index 4d4c70576e8..568b04db77f 100644 --- a/tests/plugins/lit.local.cfg +++ b/tests/plugins/lit.local.cfg @@ -24,17 +24,16 @@ if (config.plugins_supported): config.substitutions.append( ('%plugin_compile_flags', " ".join(plugin_compile_flags) ) ) # Set feature that tells us that the just-built LDC is ABI compatible with the host D compiler - # Be conservative: only set it when host LDC and just-built LDC have identical versions + # For our tets, the required ABI compatibility is OK since LDC 1.18 (interface ptr). + # If the compiler is built not by LDC but another compiler, then assume the ABI to be incompatible. command = [config.ldc2_bin, '--version'] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) text1 = p.stdout.readline() # Ex.: "LDC - the LLVM D compiler (1.33.0-git-716f627)" text2 = p.stdout.readline() # Ex.: " based on DMD v2.103.1 and LLVM 14.0.0" text3 = p.stdout.readline() # Ex.: " built with LDC - the LLVM D compiler (1.33.0-beta2)" - m = re.compile('LDC - the LLVM D compiler \((.*)\)').match(text1) - ldc_version = m.group(1) - m3 = re.compile(' built with.* \((.*)\)').match(text3) - host_version = m3.group(1) - if (ldc_version == host_version): + host_version = re.compile(' built with LDC.* \((1\.[0-9]+).*\)').match(text3).group(1) + print(host_version) + if (float(host_version) > 1.1799): config.available_features.add('ABI_compatible_with_host_D')