Skip to content

Revert ONNX CMake changes#7515

Merged
justinchuby merged 12 commits intoonnx:mainfrom
cyyever:drop_onnx_object
Dec 13, 2025
Merged

Revert ONNX CMake changes#7515
justinchuby merged 12 commits intoonnx:mainfrom
cyyever:drop_onnx_object

Conversation

@cyyever
Copy link
Copy Markdown
Contributor

@cyyever cyyever commented Dec 11, 2025

Motivation and Context

It turns out that the CMake object libraries have portability issues on some platforms.
Fixes #7514

@cyyever cyyever requested a review from a team as a code owner December 11, 2025 01:15
@github-project-automation github-project-automation Bot moved this to In progress in PR Tracker Dec 11, 2025
@cyyever cyyever force-pushed the drop_onnx_object branch 4 times, most recently from 4496608 to e3bb2d3 Compare December 11, 2025 01:31
@cyyever cyyever added the topic: build Issues related to ONNX builds and packages label Dec 11, 2025
@cyyever cyyever force-pushed the drop_onnx_object branch 3 times, most recently from 09a9f2e to 38ee775 Compare December 11, 2025 01:46
@cyyever cyyever added the run release CIs Use this label to trigger release tests in CI label Dec 11, 2025
@cyyever cyyever changed the title Revert ONNX CMake libraries Revert ONNX CMake changes Dec 11, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.25%. Comparing base (82c1c48) to head (700e6e6).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7515   +/-   ##
=======================================
  Coverage   55.25%   55.25%           
=======================================
  Files         513      513           
  Lines       32213    32213           
  Branches     2895     2895           
=======================================
  Hits        17799    17799           
  Misses      13620    13620           
  Partials      794      794           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Member

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - would it be possible to create a CI pipeline to test the xcode generator?

@github-project-automation github-project-automation Bot moved this from In progress to Reviewer approved in PR Tracker Dec 11, 2025
@cyyever
Copy link
Copy Markdown
Contributor Author

cyyever commented Dec 11, 2025

@justinchuby We can, but should be in another PR

Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: cyy <cyyever@outlook.com>
@justinchuby
Copy link
Copy Markdown
Member

One test failing?

@cyyever
Copy link
Copy Markdown
Contributor Author

cyyever commented Dec 12, 2025

@justinchuby Looks like it is flaky.

Signed-off-by: cyy <cyyever@outlook.com>
@cyyever cyyever added run release CIs Use this label to trigger release tests in CI and removed run release CIs Use this label to trigger release tests in CI labels Dec 12, 2025
Signed-off-by: cyy <cyyever@outlook.com>
@cyyever cyyever added run release CIs Use this label to trigger release tests in CI and removed run release CIs Use this label to trigger release tests in CI labels Dec 12, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts the CMake object library approach that was causing portability issues on some platforms, as reported in issue #7514. The changes simplify the build system by returning to a more traditional library structure while maintaining the same functionality.

Key changes:

  • Reverted from OBJECT libraries (onnx_object, onnx_proto_object) back to regular libraries
  • Consolidated compile options and configuration into reusable CMake functions
  • Fixed loop variable types in C++ code to use size_t with explicit casting to avoid type warnings

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
onnx/cpp2py_export.cc Changed loop variables from auto to size_t with explicit casting to int for Input/Output calls to avoid signed/unsigned comparison warnings
cmake/summary.cmake Updated target references from object library targets (onnx_object, onnx_proto_object) to regular library targets (onnx, onnx_proto)
cmake/Utils.cmake Added add_onnx_compile_options function to centralize compile options, flags, and library linking; reformatted existing functions for consistency
CMakeLists.txt Removed object library definitions and simplified build to use regular libraries; updated nanobind_add_module to include sources directly instead of linking object libraries

Comment thread cmake/Utils.cmake Outdated
Comment thread CMakeLists.txt Outdated
@justinchuby
Copy link
Copy Markdown
Member

Copilot comments look reasonable

cyyever and others added 3 commits December 13, 2025 07:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
@cyyever
Copy link
Copy Markdown
Contributor Author

cyyever commented Dec 12, 2025

@justinchuby Fixed

@justinchuby justinchuby merged commit 1d2f1d3 into onnx:main Dec 13, 2025
40 of 41 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in PR Tracker Dec 13, 2025
@justinchuby
Copy link
Copy Markdown
Member

Thank you

@cyyever cyyever deleted the drop_onnx_object branch December 13, 2025 01:33
justinchuby pushed a commit that referenced this pull request Jan 8, 2026
### Motivation and Context
It turns out that the CMake object libraries have portability issues on
some platforms.
Fixes #7514

---------

Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Signed-off-by: cyy <cyyever@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
justinchuby added a commit that referenced this pull request Jan 8, 2026
- #7505 
- #7515 
- #7524 
- #7525

---------

Signed-off-by: cyy <cyyever@outlook.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Yuanyuan Chen <cyyever@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@franramirez688
Copy link
Copy Markdown

franramirez688 commented Jan 21, 2026

Hi @cyyever @justinchuby

I had a local test which ran this case (similar to ONNXRUNTIME linking with ONNX):

# . . .

find_package(ONNX REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE onnx onnx_proto)

It compiled and linked fine, building as a dynamic library. But I noticed that using the 1.20.x release, using the same example and built as a dynamic one, I got this:

onnx/1.20.1 (test package): Running test()
onnx/1.20.1 (test package): RUN: ./test_package
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1768982174.694810 6980831 descriptor_database.cc:678] File already exists in database: onnx/onnx-ml.proto
F0000 00:00:1768982174.696511 6980831 descriptor.cc:2518] Check failed: GeneratedDatabase()->Add(encoded_file_descriptor, size)
*** Check failure stack trace: ***
    @        0x100202488  absl::lts_20250814::log_internal::LogMessage::Flush()
    @        0x100d6a854  google::protobuf::DescriptorPool::InternalAddGeneratedFile()
    @        0x100e0c928  google::protobuf::internal::AddDescriptors()
    @        0x19c27acb0  ___ZNK5dyld46Loader25findAndRunAllInitializersERNS_12RuntimeStateE_block_invoke
    @        0x19c2b8730  ___ZNK5dyld313MachOAnalyzer18forEachInitializerER11DiagnosticsRKNS0_15VMAddrConverterEU13block_pointerFvjEPKv_block_invoke.204
    @        0x19c2d7540  ___ZNK6mach_o6Header14forEachSectionEU13block_pointerFvRKNS0_11SectionInfoERbE_block_invoke
    @        0x19c2d4164  mach_o::Header::forEachLoadCommand()
    @        0x19c2d59fc  mach_o::Header::forEachSection()
    @        0x19c2b8220  dyld3::MachOAnalyzer::forEachInitializer()
    @        0x19c27aa68  dyld4::Loader::findAndRunAllInitializers()
    @        0x19c2828b0  dyld4::JustInTimeLoader::runInitializers()
    @        0x19c27b214  dyld4::Loader::runInitializersBottomUp()
    @        0x19c27b1b4  dyld4::Loader::runInitializersBottomUp()
    @        0x19c27fe50  dyld4::Loader::runInitializersBottomUpPlusUpwardLinks()::$_0::operator()()
    @        0x19c27b530  dyld4::Loader::runInitializersBottomUpPlusUpwardLinks()
    @        0x19c29d04c  dyld4::APIs::runAllInitializersForMain()
    @        0x19c25f158  dyld4::prepare()
    @        0x19c25dd04  start
/bin/sh: line 1: 64127 Abort trap: 6           ./test_package

ERROR: onnx/1.20.1 (test package): Error in test() method, line 26
	self.run(bin_path, env="conanrun")
	ConanException: Error 134 while executing

I think that it could be related to the fact that onnx target now also includes the ONNX_PROTO_SRCS https://github.com/onnx/onnx/pull/7515/changes#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR418

My question is:

  • Is that expected? Now, should I only link against onnx, as it embeds those sources too?
  • If this is not expected, do you want me to open a fresh issue?

Thanks in advance!

@cyyever
Copy link
Copy Markdown
Contributor Author

cyyever commented Jan 22, 2026

@franramirez688 Can you reproduce it with ONNX 1.20.1? If so, could you provide the problematic command?

@franramirez688
Copy link
Copy Markdown

@franramirez688 Can you reproduce it with ONNX 1.20.1? If so, could you provide the problematic command?

@cyyever I just uploaded a little repro-case here: https://github.com/franramirez688/repro-onnx-1_20_1
It's using Conan, but it's not going to pollute your local environment; it'll be contained within that folder. Anyway, if you want me to provide another repro case without Conan, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run release CIs Use this label to trigger release tests in CI topic: build Issues related to ONNX builds and packages

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Build failure with Xcode generator

4 participants