From 10f822d4a1a8afd71e0d5476417108d3cdabd7bf Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 6 Jun 2026 17:39:12 -0400 Subject: [PATCH 1/2] Fix out-of-tree build failure on Windows. Also forces Release mode in these scripts by default because apparently the typical default is Debug. --- examples/triage/CMakeLists.txt | 4 ++-- scripts/test_build_external.py | 7 +++++-- scripts/test_build_internal.py | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/triage/CMakeLists.txt b/examples/triage/CMakeLists.txt index d999c99549..7b3dd6cc51 100644 --- a/examples/triage/CMakeLists.txt +++ b/examples/triage/CMakeLists.txt @@ -9,7 +9,7 @@ file(GLOB SOURCES CONFIGURE_DEPENDS set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED) +find_package(Qt6 COMPONENTS Concurrent Core Gui Widgets REQUIRED) if(DEMO) add_library(triage STATIC ${SOURCES} ${MOCS}) @@ -28,7 +28,7 @@ if(NOT BN_API_BUILD_EXAMPLES AND NOT BN_INTERNAL_BUILD) add_subdirectory(${BN_API_PATH} api) endif() -target_link_libraries(triage binaryninjaui Qt6::Core Qt6::Gui Qt6::Widgets) +target_link_libraries(triage binaryninjaui Qt6::Concurrent Qt6::Core Qt6::Gui Qt6::Widgets) set_target_properties(triage PROPERTIES CXX_STANDARD 20 diff --git a/scripts/test_build_external.py b/scripts/test_build_external.py index e103c2b1e2..7d62ea764e 100644 --- a/scripts/test_build_external.py +++ b/scripts/test_build_external.py @@ -22,6 +22,8 @@ parser.add_argument('--cmake', default=os.environ.get('CMAKE'), help='Path to cmake. Defaults to CMAKE or PATH lookup.') parser.add_argument('--cc', default=os.environ.get('CC'), help='C compiler to use. Defaults to CC or CMake platform default.') parser.add_argument('--cxx', default=os.environ.get('CXX'), help='C++ compiler to use. Defaults to CXX or CMake platform default.') +parser.add_argument('--config', default=os.environ.get('CMAKE_BUILD_CONFIG', 'Release'), + help='CMake build configuration to use. Defaults to CMAKE_BUILD_CONFIG or Release.') parser.add_argument('--extra-project', action='append', default=[], help='Additional out-of-tree CMake project directory to build. May be specified multiple times.') args = parser.parse_args() @@ -170,9 +172,10 @@ def external_project_cmake_files(): print(f'C compiler: {configure_env.get("CC", "CMake platform default")}') print(f'C++ compiler: {configure_env.get("CXX", "CMake platform default")}') +print(f'CMake build config: {args.config}') -configure_args = [] -build_args = [] +configure_args = [f'-DCMAKE_BUILD_TYPE={args.config}'] +build_args = ['--config', args.config] if platform.system() == "Windows": configure_env['CXXFLAGS'] = f'/MP{args.parallel}' diff --git a/scripts/test_build_internal.py b/scripts/test_build_internal.py index b31f63d54b..1d335b2245 100644 --- a/scripts/test_build_internal.py +++ b/scripts/test_build_internal.py @@ -20,6 +20,8 @@ parser.add_argument('--cmake', default=os.environ.get('CMAKE'), help='Path to cmake. Defaults to CMAKE or PATH lookup.') parser.add_argument('--cc', default=os.environ.get('CC'), help='C compiler to use. Defaults to CC or CMake platform default.') parser.add_argument('--cxx', default=os.environ.get('CXX'), help='C++ compiler to use. Defaults to CXX or CMake platform default.') +parser.add_argument('--config', default=os.environ.get('CMAKE_BUILD_CONFIG', 'Release'), + help='CMake build configuration to use. Defaults to CMAKE_BUILD_CONFIG or Release.') args = parser.parse_args() api_base = Path(__file__).parent.parent.absolute() @@ -113,9 +115,10 @@ def configure_binary_ninja_env(env): print(f'C compiler: {env.get("CC", "CMake platform default")}') print(f'C++ compiler: {env.get("CXX", "CMake platform default")}') +print(f'CMake build config: {args.config}') -configure_args = ['-DBN_API_BUILD_EXAMPLES=1'] -build_args = [] +configure_args = ['-DBN_API_BUILD_EXAMPLES=1', f'-DCMAKE_BUILD_TYPE={args.config}'] +build_args = ['--config', args.config] if platform.system() == 'Windows': env['CXXFLAGS'] = f'/MP{args.parallel}' From f35b252a8f12c85c6b1b9a5a7e254c5f2b712245 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 6 Jun 2026 17:39:39 -0400 Subject: [PATCH 2/2] Add some explicit constructors clang wanted. When building the API out-of-tree on Ubuntu 22.04 with clang 14.0, I encountered some build failures. These changes fixed that. I don't fully understand why clang believes they are necessary, but it appears to. --- binaryninjaapi.h | 14 ++++++++++++++ mediumlevelilinstruction.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 5afc8a42e0..6ee4b6d058 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -5437,6 +5438,11 @@ namespace BinaryNinja { uint64_t addr; uint64_t len; + DerivedStringLocation() = default; + DerivedStringLocation(BNDerivedStringLocationType type, uint64_t address, uint64_t length) : + locationType(type), addr(address), len(length) + {} + bool operator==(const DerivedStringLocation& other) const { if (locationType != other.locationType) @@ -5477,6 +5483,11 @@ namespace BinaryNinja { std::optional location; Ref customType; + DerivedString() = default; + DerivedString(StringRef val, std::optional loc, Ref type) : + value(std::move(val)), location(std::move(loc)), customType(std::move(type)) + {} + bool operator==(const DerivedString& other) const { if (value != other.value) @@ -10815,6 +10826,9 @@ namespace BinaryNinja { { std::string name; std::string value; + + TypeAttribute() = default; + TypeAttribute(std::string name, std::string value) : name(std::move(name)), value(std::move(value)) {} }; /*! diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 00f705f634..87100c2287 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -69,6 +69,10 @@ namespace BinaryNinja Variable var; size_t version = 0; + SSAVariable() = default; + SSAVariable(const Variable& v, size_t ver) : var(v), version(ver) {} + SSAVariable(const BNVariable& v, size_t ver) : var(v), version(ver) {} + // TODO: `= default` these when we can rely on C++20 bool operator==(const SSAVariable& other) const {