[clang] 0f28d48 - SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

Tobias Hieta via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 24 23:36:17 PDT 2022


Author: H. Vetinari
Date: 2022-08-25T08:36:01+02:00
New Revision: 0f28d4856630f8b5c6708069b4e35d7345838d6b

URL: https://github.com/llvm/llvm-project/commit/0f28d4856630f8b5c6708069b4e35d7345838d6b
DIFF: https://github.com/llvm/llvm-project/commit/0f28d4856630f8b5c6708069b4e35d7345838d6b.diff

LOG: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

This reverts commit bc39d7bdd4977a953b2e102f8f7eb479ad78984e.

rename CLANG_SONAME to LIBCLANG_SOVERSION

[clang][cmake] introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

Differential Revision: https://reviews.llvm.org/D132486

Added: 
    clang/tools/libclang/libclang.map
    clang/tools/libclang/linker-script-to-export-list.py

Modified: 
    clang/CMakeLists.txt
    clang/docs/ReleaseNotes.rst
    clang/tools/libclang/CMakeLists.txt

Removed: 
    clang/tools/libclang/libclang.exports


################################################################################
diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 332df8f3b8bf5..2b1e968da3960 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -463,6 +463,12 @@ if(CLANG_ENABLE_ARCMT)
   set(CLANG_ENABLE_OBJC_REWRITER ON)
 endif()
 
+# This option is a stop-gap, we should commit to removing this as
+# soon as possible. See discussion:
+# https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/
+option(CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION
+  "Force the SOVERSION of libclang to be equal to CLANG_MAJOR" ON)
+
 # Clang version information
 set(CLANG_EXECUTABLE_VERSION
     "${CLANG_VERSION_MAJOR}" CACHE STRING

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 46339ff9ce8d1..d40f56f3f3891 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -235,6 +235,8 @@ clang-extdef-mapping
 libclang
 --------
 
+- ...
+
 Static Analyzer
 ---------------
 

diff  --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 8d95d0900e8c4..9a874ae6f85dc 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -1,3 +1,21 @@
+# The SOVERSION should be updated only if a change is made to the libclang
+# ABI, and when it is updated, it should be updated to the current
+# LLVM_VERSION_MAJOR.
+# Please also see clang/tools/libclang/libclang.map
+
+if(NOT CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION)
+  # default is to use the SOVERSION according to ABI...
+  set(LIBCLANG_SOVERSION 13)
+else()
+  # ... unless explicily overridden
+  set(LIBCLANG_SOVERSION ${CLANG_VERSION_MAJOR})
+endif()
+
+# TODO: harmonize usage of LIBCLANG_SOVERSION / LIBCLANG_LIBARY_VERSION
+#       below; this was added under time-pressure to avoid reverting the
+#       better default from LLVM 14 for LLVM 15.0.0-rc3, hence no time
+#       to clean up previous inconsistencies.
+
 set(SOURCES
   ARCMigrate.cpp
   BuildSystem.cpp
@@ -64,7 +82,8 @@ endif ()
 option(LIBCLANG_BUILD_STATIC
   "Build libclang as a static library (in addition to a shared one)" OFF)
 
-set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports)
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR}/libclang-generic.exports)
+set(LIBCLANG_VERSION_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)
 
 if(MSVC)
   # Avoid LNK4197 by not specifying libclang.exports here.
@@ -73,6 +92,20 @@ if(MSVC)
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
+if (UNIX AND NOT APPLE)
+  set(LLVM_EXPORTED_SYMBOL_FILE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
+endif()
+
+if (LLVM_EXPORTED_SYMBOL_FILE)
+  add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}
+                     COMMAND "${Python3_EXECUTABLE}"
+                       ARGS ${CMAKE_CURRENT_SOURCE_DIR}/linker-script-to-export-list.py
+                            ${LIBCLANG_VERSION_SCRIPT_FILE}
+                            ${LLVM_EXPORTED_SYMBOL_FILE}
+                     DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE})
+endif()
+
 if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC))
   set(ENABLE_SHARED SHARED)
 endif()
@@ -145,6 +178,21 @@ if(ENABLE_SHARED)
         )
     endif()
   endif()
+  if (USE_VERSION_SCRIPT)
+    target_link_options(libclang PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+    # The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+    # but requires a special option to enable it.
+    if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+      target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+    endif()
+    # Ensure that libclang.so gets rebuilt when the linker script changes.
+    set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
+                 OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)
+
+    set_target_properties(libclang PROPERTIES
+                          VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}
+                          SOVERSION ${LIBCLANG_SOVERSION})
+  endif()
 endif()
 
 if(INTERNAL_INSTALL_PREFIX)

diff  --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
deleted file mode 100644
index 639d13d21d6d3..0000000000000
--- a/clang/tools/libclang/libclang.exports
+++ /dev/null
@@ -1,395 +0,0 @@
-clang_BlockCommandComment_getArgText
-clang_BlockCommandComment_getCommandName
-clang_BlockCommandComment_getNumArgs
-clang_BlockCommandComment_getParagraph
-clang_CXCursorSet_contains
-clang_CXCursorSet_insert
-clang_CXIndex_getGlobalOptions
-clang_CXIndex_setGlobalOptions
-clang_CXIndex_setInvocationEmissionPathOption
-clang_CXRewriter_create
-clang_CXRewriter_dispose
-clang_CXRewriter_insertTextBefore
-clang_CXRewriter_overwriteChangedFiles
-clang_CXRewriter_removeText
-clang_CXRewriter_replaceText
-clang_CXRewriter_writeMainFileToStdOut
-clang_CXXConstructor_isConvertingConstructor
-clang_CXXConstructor_isCopyConstructor
-clang_CXXConstructor_isDefaultConstructor
-clang_CXXConstructor_isMoveConstructor
-clang_CXXField_isMutable
-clang_CXXMethod_isConst
-clang_CXXMethod_isDefaulted
-clang_CXXMethod_isPureVirtual
-clang_CXXMethod_isStatic
-clang_CXXMethod_isVirtual
-clang_CXXRecord_isAbstract
-clang_Comment_getChild
-clang_Comment_getKind
-clang_Comment_getNumChildren
-clang_Comment_isWhitespace
-clang_CompilationDatabase_dispose
-clang_CompilationDatabase_fromDirectory
-clang_CompilationDatabase_getAllCompileCommands
-clang_CompilationDatabase_getCompileCommands
-clang_CompileCommand_getArg
-clang_CompileCommand_getDirectory
-clang_CompileCommand_getFilename
-clang_CompileCommand_getMappedSourceContent
-clang_CompileCommand_getMappedSourcePath
-clang_CompileCommand_getNumArgs
-clang_CompileCommand_getNumMappedSources
-clang_CompileCommands_dispose
-clang_CompileCommands_getCommand
-clang_CompileCommands_getSize
-clang_Cursor_Evaluate
-clang_Cursor_getArgument
-clang_Cursor_getBriefCommentText
-clang_Cursor_getCXXManglings
-clang_Cursor_getCommentRange
-clang_Cursor_getMangling
-clang_Cursor_getModule
-clang_Cursor_getNumArguments
-clang_Cursor_getNumTemplateArguments
-clang_Cursor_getObjCDeclQualifiers
-clang_Cursor_getObjCManglings
-clang_Cursor_getObjCPropertyAttributes
-clang_Cursor_getObjCPropertyGetterName
-clang_Cursor_getObjCPropertySetterName
-clang_Cursor_getObjCSelectorIndex
-clang_Cursor_getOffsetOfField
-clang_Cursor_getParsedComment
-clang_Cursor_getRawCommentText
-clang_Cursor_getReceiverType
-clang_Cursor_getSpellingNameRange
-clang_Cursor_getStorageClass
-clang_Cursor_getTemplateArgumentKind
-clang_Cursor_getTemplateArgumentType
-clang_Cursor_getTemplateArgumentUnsignedValue
-clang_Cursor_getTemplateArgumentValue
-clang_Cursor_getTranslationUnit
-clang_Cursor_getVarDeclInitializer
-clang_Cursor_hasAttrs
-clang_Cursor_hasVarDeclExternalStorage
-clang_Cursor_hasVarDeclGlobalStorage
-clang_Cursor_isAnonymous
-clang_Cursor_isAnonymousRecordDecl
-clang_Cursor_isBitField
-clang_Cursor_isDynamicCall
-clang_Cursor_isExternalSymbol
-clang_Cursor_isFunctionInlined
-clang_Cursor_isInlineNamespace
-clang_Cursor_isMacroBuiltin
-clang_Cursor_isMacroFunctionLike
-clang_Cursor_isNull
-clang_Cursor_isObjCOptional
-clang_Cursor_isVariadic
-clang_EnumDecl_isScoped
-clang_EvalResult_dispose
-clang_EvalResult_getAsDouble
-clang_EvalResult_getAsInt
-clang_EvalResult_getAsLongLong
-clang_EvalResult_getAsStr
-clang_EvalResult_getAsUnsigned
-clang_EvalResult_getKind
-clang_EvalResult_isUnsignedInt
-clang_File_isEqual
-clang_File_tryGetRealPathName
-clang_FullComment_getAsHTML
-clang_FullComment_getAsXML
-clang_HTMLStartTagComment_isSelfClosing
-clang_HTMLStartTag_getAttrName
-clang_HTMLStartTag_getAttrValue
-clang_HTMLStartTag_getNumAttrs
-clang_HTMLTagComment_getAsString
-clang_HTMLTagComment_getTagName
-clang_IndexAction_create
-clang_IndexAction_dispose
-clang_InlineCommandComment_getArgText
-clang_InlineCommandComment_getCommandName
-clang_InlineCommandComment_getNumArgs
-clang_InlineCommandComment_getRenderKind
-clang_InlineContentComment_hasTrailingNewline
-clang_Location_isFromMainFile
-clang_Location_isInSystemHeader
-clang_ModuleMapDescriptor_create
-clang_ModuleMapDescriptor_dispose
-clang_ModuleMapDescriptor_setFrameworkModuleName
-clang_ModuleMapDescriptor_setUmbrellaHeader
-clang_ModuleMapDescriptor_writeToBuffer
-clang_Module_getASTFile
-clang_Module_getFullName
-clang_Module_getName
-clang_Module_getNumTopLevelHeaders
-clang_Module_getParent
-clang_Module_getTopLevelHeader
-clang_Module_isSystem
-clang_ParamCommandComment_getDirection
-clang_ParamCommandComment_getParamIndex
-clang_ParamCommandComment_getParamName
-clang_ParamCommandComment_isDirectionExplicit
-clang_ParamCommandComment_isParamIndexValid
-clang_PrintingPolicy_dispose
-clang_PrintingPolicy_getProperty
-clang_PrintingPolicy_setProperty
-clang_Range_isNull
-clang_TParamCommandComment_getDepth
-clang_TParamCommandComment_getIndex
-clang_TParamCommandComment_getParamName
-clang_TParamCommandComment_isParamPositionValid
-clang_TargetInfo_dispose
-clang_TargetInfo_getPointerWidth
-clang_TargetInfo_getTriple
-clang_TextComment_getText
-clang_Type_getAlignOf
-clang_Type_getCXXRefQualifier
-clang_Type_getClassType
-clang_Type_getModifiedType
-clang_Type_getNamedType
-clang_Type_getNullability
-clang_Type_getNumObjCProtocolRefs
-clang_Type_getNumObjCTypeArgs
-clang_Type_getNumTemplateArguments
-clang_Type_getObjCEncoding
-clang_Type_getObjCObjectBaseType
-clang_Type_getObjCProtocolDecl
-clang_Type_getObjCTypeArg
-clang_Type_getOffsetOf
-clang_Type_getSizeOf
-clang_Type_getTemplateArgumentAsType
-clang_Type_getValueType
-clang_Type_isTransparentTagTypedef
-clang_Type_visitFields
-clang_VerbatimBlockLineComment_getText
-clang_VerbatimLineComment_getText
-clang_VirtualFileOverlay_addFileMapping
-clang_VirtualFileOverlay_create
-clang_VirtualFileOverlay_dispose
-clang_VirtualFileOverlay_setCaseSensitivity
-clang_VirtualFileOverlay_writeToBuffer
-clang_annotateTokens
-clang_codeCompleteAt
-clang_codeCompleteGetContainerKind
-clang_codeCompleteGetContainerUSR
-clang_codeCompleteGetContexts
-clang_codeCompleteGetDiagnostic
-clang_codeCompleteGetNumDiagnostics
-clang_codeCompleteGetObjCSelector
-clang_constructUSR_ObjCCategory
-clang_constructUSR_ObjCClass
-clang_constructUSR_ObjCIvar
-clang_constructUSR_ObjCMethod
-clang_constructUSR_ObjCProperty
-clang_constructUSR_ObjCProtocol
-clang_createCXCursorSet
-clang_createIndex
-clang_createTranslationUnit
-clang_createTranslationUnit2
-clang_createTranslationUnitFromSourceFile
-clang_defaultCodeCompleteOptions
-clang_defaultDiagnosticDisplayOptions
-clang_defaultEditingTranslationUnitOptions
-clang_defaultReparseOptions
-clang_defaultSaveOptions
-clang_disposeCXCursorSet
-clang_disposeCXPlatformAvailability
-clang_disposeCXTUResourceUsage
-clang_disposeCodeCompleteResults
-clang_disposeDiagnostic
-clang_disposeDiagnosticSet
-clang_disposeIndex
-clang_disposeOverriddenCursors
-clang_disposeSourceRangeList
-clang_disposeString
-clang_disposeStringSet
-clang_disposeTokens
-clang_disposeTranslationUnit
-clang_enableStackTraces
-clang_equalCursors
-clang_equalLocations
-clang_equalRanges
-clang_equalTypes
-clang_executeOnThread
-clang_findIncludesInFile
-clang_findIncludesInFileWithBlock
-clang_findReferencesInFile
-clang_findReferencesInFileWithBlock
-clang_formatDiagnostic
-clang_free
-clang_getAddressSpace
-clang_getAllSkippedRanges
-clang_getArgType
-clang_getArrayElementType
-clang_getArraySize
-clang_getBuildSessionTimestamp
-clang_getCString
-clang_getCXTUResourceUsage
-clang_getCXXAccessSpecifier
-clang_getCanonicalCursor
-clang_getCanonicalType
-clang_getChildDiagnostics
-clang_getClangVersion
-clang_getCompletionAnnotation
-clang_getCompletionAvailability
-clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionNumFixIts
-clang_getCompletionParent
-clang_getCompletionPriority
-clang_getCursor
-clang_getCursorAvailability
-clang_getCursorCompletionString
-clang_getCursorDefinition
-clang_getCursorDisplayName
-clang_getCursorExceptionSpecificationType
-clang_getCursorExtent
-clang_getCursorKind
-clang_getCursorKindSpelling
-clang_getCursorLanguage
-clang_getCursorLexicalParent
-clang_getCursorLinkage
-clang_getCursorLocation
-clang_getCursorPlatformAvailability
-clang_getCursorPrettyPrinted
-clang_getCursorPrintingPolicy
-clang_getCursorReferenceNameRange
-clang_getCursorReferenced
-clang_getCursorResultType
-clang_getCursorSemanticParent
-clang_getCursorSpelling
-clang_getCursorTLSKind
-clang_getCursorType
-clang_getCursorUSR
-clang_getCursorVisibility
-clang_getDeclObjCTypeEncoding
-clang_getDefinitionSpellingAndExtent
-clang_getDiagnostic
-clang_getDiagnosticCategory
-clang_getDiagnosticCategoryName
-clang_getDiagnosticCategoryText
-clang_getDiagnosticFixIt
-clang_getDiagnosticInSet
-clang_getDiagnosticLocation
-clang_getDiagnosticNumFixIts
-clang_getDiagnosticNumRanges
-clang_getDiagnosticOption
-clang_getDiagnosticRange
-clang_getDiagnosticSetFromTU
-clang_getDiagnosticSeverity
-clang_getDiagnosticSpelling
-clang_getElementType
-clang_getEnumConstantDeclUnsignedValue
-clang_getEnumConstantDeclValue
-clang_getEnumDeclIntegerType
-clang_getExceptionSpecificationType
-clang_getExpansionLocation
-clang_getFieldDeclBitWidth
-clang_getFile
-clang_getFileContents
-clang_getFileLocation
-clang_getFileName
-clang_getFileTime
-clang_getFileUniqueID
-clang_getFunctionTypeCallingConv
-clang_getIBOutletCollectionType
-clang_getIncludedFile
-clang_getInclusions
-clang_getInstantiationLocation
-clang_getLocation
-clang_getLocationForOffset
-clang_getModuleForFile
-clang_getNullCursor
-clang_getNullLocation
-clang_getNullRange
-clang_getNumArgTypes
-clang_getNumCompletionChunks
-clang_getNumDiagnostics
-clang_getNumDiagnosticsInSet
-clang_getNumElements
-clang_getNumOverloadedDecls
-clang_getOverloadedDecl
-clang_getOverriddenCursors
-clang_getPointeeType
-clang_getPresumedLocation
-clang_getRange
-clang_getRangeEnd
-clang_getRangeStart
-clang_getRemappings
-clang_getRemappingsFromFileList
-clang_getResultType
-clang_getSkippedRanges
-clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
-clang_getTokenSpelling
-clang_getTranslationUnitCursor
-clang_getTranslationUnitSpelling
-clang_getTranslationUnitTargetInfo
-clang_getTypeDeclaration
-clang_getTypeKindSpelling
-clang_getTypeSpelling
-clang_getTypedefDeclUnderlyingType
-clang_getTypedefName
-clang_hashCursor
-clang_indexLoc_getCXSourceLocation
-clang_indexLoc_getFileLocation
-clang_indexSourceFile
-clang_indexSourceFileFullArgv
-clang_indexTranslationUnit
-clang_index_getCXXClassDeclInfo
-clang_index_getClientContainer
-clang_index_getClientEntity
-clang_index_getIBOutletCollectionAttrInfo
-clang_index_getObjCCategoryDeclInfo
-clang_index_getObjCContainerDeclInfo
-clang_index_getObjCInterfaceDeclInfo
-clang_index_getObjCPropertyDeclInfo
-clang_index_getObjCProtocolRefListInfo
-clang_index_isEntityObjCContainerKind
-clang_index_setClientContainer
-clang_index_setClientEntity
-clang_install_aborting_llvm_fatal_error_handler
-clang_isAttribute
-clang_isConstQualifiedType
-clang_isCursorDefinition
-clang_isDeclaration
-clang_isExpression
-clang_isFileMultipleIncludeGuarded
-clang_isFunctionTypeVariadic
-clang_isInvalid
-clang_isInvalidDeclaration
-clang_isPODType
-clang_isPreprocessing
-clang_isReference
-clang_isRestrictQualifiedType
-clang_isStatement
-clang_isTranslationUnit
-clang_isUnexposed
-clang_isVirtualBase
-clang_isVolatileQualifiedType
-clang_loadDiagnostics
-clang_parseTranslationUnit
-clang_parseTranslationUnit2
-clang_parseTranslationUnit2FullArgv
-clang_remap_dispose
-clang_remap_getFilenames
-clang_remap_getNumFiles
-clang_reparseTranslationUnit
-clang_saveTranslationUnit
-clang_sortCodeCompletionResults
-clang_suspendTranslationUnit
-clang_toggleCrashRecovery
-clang_tokenize
-clang_uninstall_llvm_fatal_error_handler
-clang_visitChildren
-clang_visitChildrenWithBlock

diff  --git a/clang/tools/libclang/libclang.map b/clang/tools/libclang/libclang.map
new file mode 100644
index 0000000000000..716e2474966d5
--- /dev/null
+++ b/clang/tools/libclang/libclang.map
@@ -0,0 +1,413 @@
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
+
+LLVM_13 {
+  global:
+    clang_BlockCommandComment_getArgText;
+    clang_BlockCommandComment_getCommandName;
+    clang_BlockCommandComment_getNumArgs;
+    clang_BlockCommandComment_getParagraph;
+    clang_CXCursorSet_contains;
+    clang_CXCursorSet_insert;
+    clang_CXIndex_getGlobalOptions;
+    clang_CXIndex_setGlobalOptions;
+    clang_CXIndex_setInvocationEmissionPathOption;
+    clang_CXRewriter_create;
+    clang_CXRewriter_dispose;
+    clang_CXRewriter_insertTextBefore;
+    clang_CXRewriter_overwriteChangedFiles;
+    clang_CXRewriter_removeText;
+    clang_CXRewriter_replaceText;
+    clang_CXRewriter_writeMainFileToStdOut;
+    clang_CXXConstructor_isConvertingConstructor;
+    clang_CXXConstructor_isCopyConstructor;
+    clang_CXXConstructor_isDefaultConstructor;
+    clang_CXXConstructor_isMoveConstructor;
+    clang_CXXField_isMutable;
+    clang_CXXMethod_isConst;
+    clang_CXXMethod_isDefaulted;
+    clang_CXXMethod_isPureVirtual;
+    clang_CXXMethod_isStatic;
+    clang_CXXMethod_isVirtual;
+    clang_CXXRecord_isAbstract;
+    clang_Comment_getChild;
+    clang_Comment_getKind;
+    clang_Comment_getNumChildren;
+    clang_Comment_isWhitespace;
+    clang_CompilationDatabase_dispose;
+    clang_CompilationDatabase_fromDirectory;
+    clang_CompilationDatabase_getAllCompileCommands;
+    clang_CompilationDatabase_getCompileCommands;
+    clang_CompileCommand_getArg;
+    clang_CompileCommand_getDirectory;
+    clang_CompileCommand_getFilename;
+    clang_CompileCommand_getMappedSourceContent;
+    clang_CompileCommand_getMappedSourcePath;
+    clang_CompileCommand_getNumArgs;
+    clang_CompileCommand_getNumMappedSources;
+    clang_CompileCommands_dispose;
+    clang_CompileCommands_getCommand;
+    clang_CompileCommands_getSize;
+    clang_Cursor_Evaluate;
+    clang_Cursor_getArgument;
+    clang_Cursor_getBriefCommentText;
+    clang_Cursor_getCXXManglings;
+    clang_Cursor_getCommentRange;
+    clang_Cursor_getMangling;
+    clang_Cursor_getModule;
+    clang_Cursor_getNumArguments;
+    clang_Cursor_getNumTemplateArguments;
+    clang_Cursor_getObjCDeclQualifiers;
+    clang_Cursor_getObjCManglings;
+    clang_Cursor_getObjCPropertyAttributes;
+    clang_Cursor_getObjCPropertyGetterName;
+    clang_Cursor_getObjCPropertySetterName;
+    clang_Cursor_getObjCSelectorIndex;
+    clang_Cursor_getOffsetOfField;
+    clang_Cursor_getParsedComment;
+    clang_Cursor_getRawCommentText;
+    clang_Cursor_getReceiverType;
+    clang_Cursor_getSpellingNameRange;
+    clang_Cursor_getStorageClass;
+    clang_Cursor_getTemplateArgumentKind;
+    clang_Cursor_getTemplateArgumentType;
+    clang_Cursor_getTemplateArgumentUnsignedValue;
+    clang_Cursor_getTemplateArgumentValue;
+    clang_Cursor_getTranslationUnit;
+    clang_Cursor_getVarDeclInitializer;
+    clang_Cursor_hasAttrs;
+    clang_Cursor_hasVarDeclExternalStorage;
+    clang_Cursor_hasVarDeclGlobalStorage;
+    clang_Cursor_isAnonymous;
+    clang_Cursor_isAnonymousRecordDecl;
+    clang_Cursor_isBitField;
+    clang_Cursor_isDynamicCall;
+    clang_Cursor_isExternalSymbol;
+    clang_Cursor_isFunctionInlined;
+    clang_Cursor_isInlineNamespace;
+    clang_Cursor_isMacroBuiltin;
+    clang_Cursor_isMacroFunctionLike;
+    clang_Cursor_isNull;
+    clang_Cursor_isObjCOptional;
+    clang_Cursor_isVariadic;
+    clang_EnumDecl_isScoped;
+    clang_EvalResult_dispose;
+    clang_EvalResult_getAsDouble;
+    clang_EvalResult_getAsInt;
+    clang_EvalResult_getAsLongLong;
+    clang_EvalResult_getAsStr;
+    clang_EvalResult_getAsUnsigned;
+    clang_EvalResult_getKind;
+    clang_EvalResult_isUnsignedInt;
+    clang_File_isEqual;
+    clang_File_tryGetRealPathName;
+    clang_FullComment_getAsHTML;
+    clang_FullComment_getAsXML;
+    clang_HTMLStartTagComment_isSelfClosing;
+    clang_HTMLStartTag_getAttrName;
+    clang_HTMLStartTag_getAttrValue;
+    clang_HTMLStartTag_getNumAttrs;
+    clang_HTMLTagComment_getAsString;
+    clang_HTMLTagComment_getTagName;
+    clang_IndexAction_create;
+    clang_IndexAction_dispose;
+    clang_InlineCommandComment_getArgText;
+    clang_InlineCommandComment_getCommandName;
+    clang_InlineCommandComment_getNumArgs;
+    clang_InlineCommandComment_getRenderKind;
+    clang_InlineContentComment_hasTrailingNewline;
+    clang_Location_isFromMainFile;
+    clang_Location_isInSystemHeader;
+    clang_ModuleMapDescriptor_create;
+    clang_ModuleMapDescriptor_dispose;
+    clang_ModuleMapDescriptor_setFrameworkModuleName;
+    clang_ModuleMapDescriptor_setUmbrellaHeader;
+    clang_ModuleMapDescriptor_writeToBuffer;
+    clang_Module_getASTFile;
+    clang_Module_getFullName;
+    clang_Module_getName;
+    clang_Module_getNumTopLevelHeaders;
+    clang_Module_getParent;
+    clang_Module_getTopLevelHeader;
+    clang_Module_isSystem;
+    clang_ParamCommandComment_getDirection;
+    clang_ParamCommandComment_getParamIndex;
+    clang_ParamCommandComment_getParamName;
+    clang_ParamCommandComment_isDirectionExplicit;
+    clang_ParamCommandComment_isParamIndexValid;
+    clang_PrintingPolicy_dispose;
+    clang_PrintingPolicy_getProperty;
+    clang_PrintingPolicy_setProperty;
+    clang_Range_isNull;
+    clang_TParamCommandComment_getDepth;
+    clang_TParamCommandComment_getIndex;
+    clang_TParamCommandComment_getParamName;
+    clang_TParamCommandComment_isParamPositionValid;
+    clang_TargetInfo_dispose;
+    clang_TargetInfo_getPointerWidth;
+    clang_TargetInfo_getTriple;
+    clang_TextComment_getText;
+    clang_Type_getAlignOf;
+    clang_Type_getCXXRefQualifier;
+    clang_Type_getClassType;
+    clang_Type_getModifiedType;
+    clang_Type_getNamedType;
+    clang_Type_getNullability;
+    clang_Type_getNumObjCProtocolRefs;
+    clang_Type_getNumObjCTypeArgs;
+    clang_Type_getNumTemplateArguments;
+    clang_Type_getObjCEncoding;
+    clang_Type_getObjCObjectBaseType;
+    clang_Type_getObjCProtocolDecl;
+    clang_Type_getObjCTypeArg;
+    clang_Type_getOffsetOf;
+    clang_Type_getSizeOf;
+    clang_Type_getTemplateArgumentAsType;
+    clang_Type_getValueType;
+    clang_Type_isTransparentTagTypedef;
+    clang_Type_visitFields;
+    clang_VerbatimBlockLineComment_getText;
+    clang_VerbatimLineComment_getText;
+    clang_VirtualFileOverlay_addFileMapping;
+    clang_VirtualFileOverlay_create;
+    clang_VirtualFileOverlay_dispose;
+    clang_VirtualFileOverlay_setCaseSensitivity;
+    clang_VirtualFileOverlay_writeToBuffer;
+    clang_annotateTokens;
+    clang_codeCompleteAt;
+    clang_codeCompleteGetContainerKind;
+    clang_codeCompleteGetContainerUSR;
+    clang_codeCompleteGetContexts;
+    clang_codeCompleteGetDiagnostic;
+    clang_codeCompleteGetNumDiagnostics;
+    clang_codeCompleteGetObjCSelector;
+    clang_constructUSR_ObjCCategory;
+    clang_constructUSR_ObjCClass;
+    clang_constructUSR_ObjCIvar;
+    clang_constructUSR_ObjCMethod;
+    clang_constructUSR_ObjCProperty;
+    clang_constructUSR_ObjCProtocol;
+    clang_createCXCursorSet;
+    clang_createIndex;
+    clang_createTranslationUnit;
+    clang_createTranslationUnit2;
+    clang_createTranslationUnitFromSourceFile;
+    clang_defaultCodeCompleteOptions;
+    clang_defaultDiagnosticDisplayOptions;
+    clang_defaultEditingTranslationUnitOptions;
+    clang_defaultReparseOptions;
+    clang_defaultSaveOptions;
+    clang_disposeCXCursorSet;
+    clang_disposeCXPlatformAvailability;
+    clang_disposeCXTUResourceUsage;
+    clang_disposeCodeCompleteResults;
+    clang_disposeDiagnostic;
+    clang_disposeDiagnosticSet;
+    clang_disposeIndex;
+    clang_disposeOverriddenCursors;
+    clang_disposeSourceRangeList;
+    clang_disposeString;
+    clang_disposeStringSet;
+    clang_disposeTokens;
+    clang_disposeTranslationUnit;
+    clang_enableStackTraces;
+    clang_equalCursors;
+    clang_equalLocations;
+    clang_equalRanges;
+    clang_equalTypes;
+    clang_executeOnThread;
+    clang_findIncludesInFile;
+    clang_findIncludesInFileWithBlock;
+    clang_findReferencesInFile;
+    clang_findReferencesInFileWithBlock;
+    clang_formatDiagnostic;
+    clang_free;
+    clang_getAddressSpace;
+    clang_getAllSkippedRanges;
+    clang_getArgType;
+    clang_getArrayElementType;
+    clang_getArraySize;
+    clang_getBuildSessionTimestamp;
+    clang_getCString;
+    clang_getCXTUResourceUsage;
+    clang_getCXXAccessSpecifier;
+    clang_getCanonicalCursor;
+    clang_getCanonicalType;
+    clang_getChildDiagnostics;
+    clang_getClangVersion;
+    clang_getCompletionAnnotation;
+    clang_getCompletionAvailability;
+    clang_getCompletionBriefComment;
+    clang_getCompletionChunkCompletionString;
+    clang_getCompletionChunkKind;
+    clang_getCompletionChunkText;
+    clang_getCompletionFixIt;
+    clang_getCompletionNumAnnotations;
+    clang_getCompletionNumFixIts;
+    clang_getCompletionParent;
+    clang_getCompletionPriority;
+    clang_getCursor;
+    clang_getCursorAvailability;
+    clang_getCursorCompletionString;
+    clang_getCursorDefinition;
+    clang_getCursorDisplayName;
+    clang_getCursorExceptionSpecificationType;
+    clang_getCursorExtent;
+    clang_getCursorKind;
+    clang_getCursorKindSpelling;
+    clang_getCursorLanguage;
+    clang_getCursorLexicalParent;
+    clang_getCursorLinkage;
+    clang_getCursorLocation;
+    clang_getCursorPlatformAvailability;
+    clang_getCursorPrettyPrinted;
+    clang_getCursorPrintingPolicy;
+    clang_getCursorReferenceNameRange;
+    clang_getCursorReferenced;
+    clang_getCursorResultType;
+    clang_getCursorSemanticParent;
+    clang_getCursorSpelling;
+    clang_getCursorTLSKind;
+    clang_getCursorType;
+    clang_getCursorUSR;
+    clang_getCursorVisibility;
+    clang_getDeclObjCTypeEncoding;
+    clang_getDefinitionSpellingAndExtent;
+    clang_getDiagnostic;
+    clang_getDiagnosticCategory;
+    clang_getDiagnosticCategoryName;
+    clang_getDiagnosticCategoryText;
+    clang_getDiagnosticFixIt;
+    clang_getDiagnosticInSet;
+    clang_getDiagnosticLocation;
+    clang_getDiagnosticNumFixIts;
+    clang_getDiagnosticNumRanges;
+    clang_getDiagnosticOption;
+    clang_getDiagnosticRange;
+    clang_getDiagnosticSetFromTU;
+    clang_getDiagnosticSeverity;
+    clang_getDiagnosticSpelling;
+    clang_getElementType;
+    clang_getEnumConstantDeclUnsignedValue;
+    clang_getEnumConstantDeclValue;
+    clang_getEnumDeclIntegerType;
+    clang_getExceptionSpecificationType;
+    clang_getExpansionLocation;
+    clang_getFieldDeclBitWidth;
+    clang_getFile;
+    clang_getFileContents;
+    clang_getFileLocation;
+    clang_getFileName;
+    clang_getFileTime;
+    clang_getFileUniqueID;
+    clang_getFunctionTypeCallingConv;
+    clang_getIBOutletCollectionType;
+    clang_getIncludedFile;
+    clang_getInclusions;
+    clang_getInstantiationLocation;
+    clang_getLocation;
+    clang_getLocationForOffset;
+    clang_getModuleForFile;
+    clang_getNullCursor;
+    clang_getNullLocation;
+    clang_getNullRange;
+    clang_getNumArgTypes;
+    clang_getNumCompletionChunks;
+    clang_getNumDiagnostics;
+    clang_getNumDiagnosticsInSet;
+    clang_getNumElements;
+    clang_getNumOverloadedDecls;
+    clang_getOverloadedDecl;
+    clang_getOverriddenCursors;
+    clang_getPointeeType;
+    clang_getPresumedLocation;
+    clang_getRange;
+    clang_getRangeEnd;
+    clang_getRangeStart;
+    clang_getRemappings;
+    clang_getRemappingsFromFileList;
+    clang_getResultType;
+    clang_getSkippedRanges;
+    clang_getSpecializedCursorTemplate;
+    clang_getSpellingLocation;
+    clang_getTUResourceUsageName;
+    clang_getTemplateCursorKind;
+    clang_getToken;
+    clang_getTokenExtent;
+    clang_getTokenKind;
+    clang_getTokenLocation;
+    clang_getTokenSpelling;
+    clang_getTranslationUnitCursor;
+    clang_getTranslationUnitSpelling;
+    clang_getTranslationUnitTargetInfo;
+    clang_getTypeDeclaration;
+    clang_getTypeKindSpelling;
+    clang_getTypeSpelling;
+    clang_getTypedefDeclUnderlyingType;
+    clang_getTypedefName;
+    clang_hashCursor;
+    clang_indexLoc_getCXSourceLocation;
+    clang_indexLoc_getFileLocation;
+    clang_indexSourceFile;
+    clang_indexSourceFileFullArgv;
+    clang_indexTranslationUnit;
+    clang_index_getCXXClassDeclInfo;
+    clang_index_getClientContainer;
+    clang_index_getClientEntity;
+    clang_index_getIBOutletCollectionAttrInfo;
+    clang_index_getObjCCategoryDeclInfo;
+    clang_index_getObjCContainerDeclInfo;
+    clang_index_getObjCInterfaceDeclInfo;
+    clang_index_getObjCPropertyDeclInfo;
+    clang_index_getObjCProtocolRefListInfo;
+    clang_index_isEntityObjCContainerKind;
+    clang_index_setClientContainer;
+    clang_index_setClientEntity;
+    clang_install_aborting_llvm_fatal_error_handler;
+    clang_isAttribute;
+    clang_isConstQualifiedType;
+    clang_isCursorDefinition;
+    clang_isDeclaration;
+    clang_isExpression;
+    clang_isFileMultipleIncludeGuarded;
+    clang_isFunctionTypeVariadic;
+    clang_isInvalid;
+    clang_isInvalidDeclaration;
+    clang_isPODType;
+    clang_isPreprocessing;
+    clang_isReference;
+    clang_isRestrictQualifiedType;
+    clang_isStatement;
+    clang_isTranslationUnit;
+    clang_isUnexposed;
+    clang_isVirtualBase;
+    clang_isVolatileQualifiedType;
+    clang_loadDiagnostics;
+    clang_parseTranslationUnit;
+    clang_parseTranslationUnit2;
+    clang_parseTranslationUnit2FullArgv;
+    clang_remap_dispose;
+    clang_remap_getFilenames;
+    clang_remap_getNumFiles;
+    clang_reparseTranslationUnit;
+    clang_saveTranslationUnit;
+    clang_sortCodeCompletionResults;
+    clang_suspendTranslationUnit;
+    clang_toggleCrashRecovery;
+    clang_tokenize;
+    clang_uninstall_llvm_fatal_error_handler;
+    clang_visitChildren;
+    clang_visitChildrenWithBlock;
+
+  local: *;
+};
+
+# Example of how to add a new symbol version entry.  If you do add a new symbol
+# version, please update the example to depend on the version you added.
+# LLVM_X {
+# global:
+#   clang_newsymbol;
+# };

diff  --git a/clang/tools/libclang/linker-script-to-export-list.py b/clang/tools/libclang/linker-script-to-export-list.py
new file mode 100644
index 0000000000000..37fb172b9a0a2
--- /dev/null
+++ b/clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,11 @@
+import re
+import os
+import sys
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2], 'w')
+
+for line in input_file:
+    m = re.search('^\s+(clang_[^;]+)', line)
+    if m:
+        output_file.write(m.group(1) + "\n")


        


More information about the cfe-commits mailing list