Skip to content

Missing Symbols due to visibility setting change #7178

@Sunny-Anand

Description

@Sunny-Anand

Bug Report

Is the issue related to model conversion?

Describe the bug

Upgrading onnx from 1.17.0 to 1.18.0 in onnx-mlir, ran into an issue when trying to build onnx-mlir with BUILD_SHARED_LIBS ON setting for onnx in the libOMBuilder FrontendDialectTransformer.cpp, where it complained about missing onnx symbols for initially the below functions

Undefined symbols for architecture arm64:
  "onnx::OnnxParser::Parse(onnx::ModelProto&)", referenced from:
      onnx_mlir::ImportFrontendModelFile(llvm::StringRef, mlir::MLIRContext&, mlir::OwningOpRef<mlir::ModuleOp>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, onnx_mlir::ImportOptions) in FrontendDialectTransformer.cpp.o
  "onnx::OpSchemaRegistry::map()", referenced from:
      onnx::OpSchemaRegistry::Schema(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in FrontendDialectTransformer.cpp.o
  "onnx::version_conversion::ConvertVersion(onnx::ModelProto const&, int)", referenced from:
      onnx_mlir::ImportFrontendModelInternal(onnx::ModelProto&, mlir::MLIRContext&, mlir::OwningOpRef<mlir::ModuleOp>&, onnx_mlir::ImportOptions) in FrontendDialectTransformer.cpp.o
  "onnx::Common::Status::ErrorMessage() const", referenced from:
      onnx_mlir::ImportFrontendModelFile(llvm::StringRef, mlir::MLIRContext&, mlir::OwningOpRef<mlir::ModuleOp>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, onnx_mlir::ImportOptions) in FrontendDialectTransformer.cpp.o
  "onnx::Common::Status::IsOK() const", referenced from:
      onnx_mlir::ImportFrontendModelFile(llvm::StringRef, mlir::MLIRContext&, mlir::OwningOpRef<mlir::ModuleOp>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, onnx_mlir::ImportOptions) in FrontendDialectTransformer.cpp.o
  "onnx::OpSchema::GetFunction(int, bool) const", referenced from:
      onnx_mlir::detail::FrontendGenImpl::ImportFunctionCallNode(onnx::NodeProto const&, onnx::OpSchema const*, onnx::FunctionProto const*) in FrontendDialectTransformer.cpp.o
  "onnx::OpSchema::BuildContextDependentFunction(onnx::FunctionBodyBuildContext const&, onnx::FunctionProto&, int) const", referenced from:
      onnx_mlir::detail::FrontendGenImpl::ImportFunctionCallNode(onnx::NodeProto const&, onnx::OpSchema const*, onnx::FunctionProto const*) in FrontendDialectTransformer.cpp.o
ld: symbol(s) not found for architecture arm64

Below is the first list of missing symbols that could be fixed with @justinchuby's suggestion.


onnx::OpSchemaRegistry::map()
onnx::OnnxParser::Parse(onnx::ModelProto&)
onnx::version_conversion::ConvertVersion(onnx::ModelProto const&, int)
onnx::Common::Status::ErrorMessage() const
onnx::Common::Status::IsOK() const
onnx::OpSchema::GetFunction(int, bool) const
onnx::OpSchema::BuildContextDependentFunction(onnx::FunctionBodyBuildContext const&, onnx::FunctionProto&, int) const

Second list: Have to validate if these can be fixed with the above solution.


Undefined symbols for architecture arm64:
  "onnx::MakeAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, onnx::TensorProto const&)", referenced from:
      onnx::FunctionBodyHelper::AttributeProtoWrapper::AttributeProtoWrapper<onnx::TensorProto>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, onnx::TensorProto const&) in TestCustomFn.cpp.o
  "onnx::OpSchemaRegistry::DomainToVersionRange::Instance()", referenced from:
      onnx::OpSchemaRegistry::OpSchemaRegisterOnce::CheckDomainAndVersionToRegister(onnx::OpSchema const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in TestCustomFn.cpp.o
  "onnx::OpSchemaRegistry::GetMapWithoutEnsuringRegistration()", referenced from:
      onnx::OpSchemaRegistry::OpSchemaRegisterOnce::OpSchemaRegisterImpl(onnx::OpSchema&&, int, bool) in TestCustomFn.cpp.o
  "onnx::FunctionBodyHelper::BuildNodes(std::__1::vector<onnx::FunctionBodyHelper::NodeDef, std::__1::allocator<onnx::FunctionBodyHelper::NodeDef>> const&)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::propagateElemTypeFromInputToOutput(onnx::InferenceContext&, unsigned long, unsigned long)", referenced from:
      onnx::propagateShapeAndTypeFromFirstInput(onnx::InferenceContext&) in TestCustomFn.cpp.o
  "onnx::OpSchema::FunctionBody(std::__1::vector<onnx::NodeProto, std::__1::allocator<onnx::NodeProto>> const&, int)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::SinceVersion(int)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
      onnx::OpSchemaRegistry::OpSchemaRegisterOnce::OpSchemaRegisterImpl(onnx::OpSchema&&, int, bool) in TestCustomFn.cpp.o
  "onnx::OpSchema::TypeConstraint(char const*, std::initializer_list<char const*>, char const*)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::TypeAndShapeInferenceFunction(std::__1::function<void (onnx::InferenceContext&)>)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::Input(int, char const*, char const*, char const*, onnx::OpSchema::FormalParameterOption, bool, int, onnx::OpSchema::DifferentiationCategory)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::Output(int, char const*, char const*, char const*, onnx::OpSchema::FormalParameterOption, bool, int, onnx::OpSchema::DifferentiationCategory)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::SetName(char const*)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::OpSchema::Finalize()", referenced from:
      onnx::OpSchemaRegistry::OpSchemaRegisterOnce::OpSchemaRegisterImpl(onnx::OpSchema&&, int, bool) in TestCustomFn.cpp.o
  "onnx::OpSchema::SetDomain(char const*)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterFunSchema() in TestCustomFn.cpp.o
      RegisterOptParamFunSchema() in TestCustomFn.cpp.o
  "onnx::TensorProto onnx::ToTensor<float>(float const&)", referenced from:
      RegisterFunSchema() in TestCustomFn.cpp.o
ld: symbol(s) not found for architecture arm64

System information

Reproduction instructions

Build onnx-mlir with [set(BUILD_SHARED_LIBS ON)](https://github.com/onnx/onnx-mlir/blob/b892b39d30fb67095161f2511698d585e76bb72d/MLIR.cmake#L40) in MLIR.cmake file in onnx-mlir repo.

Expected behavior

Be able to build in BUILD_SHARED_LIBS ON without running into missing symbols issue.

Notes

Blocker for onnx-mlir to upgrade to 1.18, will remain blocker if not fixed in time for 1.19.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: buildIssues related to ONNX builds and packages

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions