Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Compilation error on FreeBSD #18284

Closed
bootkernel opened this issue Nov 4, 2023 · 4 comments
Closed

[Build] Compilation error on FreeBSD #18284

bootkernel opened this issue Nov 4, 2023 · 4 comments
Labels
build build issues; typically submitted using template

Comments

@bootkernel
Copy link

bootkernel commented Nov 4, 2023

Describe the issue

I tried to compile onnxruntime on FreeBSD but encountered the following error. This is the command I used:
./build.sh --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --allow_running_as_root

Urgency

No response

Target platform

FreeBSD 13.2-RELEASE

Build script

#!/usr/local/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Get directory this script is in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OS=$(uname -s)

if [ "$OS" = "Darwin" ]; then
    DIR_OS="MacOS"
else
    DIR_OS="linux"
fi

if [[ "$*" == *"--ios"* ]]; then
    DIR_OS="iOS"
elif [[ "$*" == *"--android"* ]]; then
    DIR_OS="Android"
fi

python3 $DIR/tools/ci_build/build.py --build_dir $DIR/build/$DIR_OS "$@"

Error / output

2023-11-04 14:26:19,276 tools_python_utils [INFO] - flatbuffers module is not installed. parse_config will not be available
2023-11-04 14:26:19,289 build [DEBUG] - Command line arguments:
  --build_dir /root/Download/onnxruntime/build/linux --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --allow_running_as_
Namespace(build_dir='/root/Download/onnxruntime/build/linux', config=['RelWithDebInfo'], update=False, build=False, clean=False, parallel=0, nvcc_threads=-1, test=False, skip_ter
2023-11-04 14:26:19,396 build [DEBUG] - Defaulting to running update, build [and test for native builds].
2023-11-04 14:26:19,405 build [INFO] - Build started
2023-11-04 14:26:19,407 build [INFO] - Generating CMake build tree
2023-11-04 14:26:19,410 build [INFO] - /usr/local/bin/cmake /root/Download/onnxruntime/cmake --compile-no-warning-as-error -Donnxruntime_RUN_ONNX_TESTS=OFF -Donnxruntime_GENERATF
Ignoring COMPILE_WARNING_AS_ERROR target property and CMAKE_COMPILE_WARNING_AS_ERROR variable.
CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):
  The OLD behavior for policy CMP0104 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- The C compiler identification is Clang 14.0.5
-- The CXX compiler identification is Clang 14.0.5
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Building ONNX Runtime for amd64
-- Performing Test COMPILER_SUPPORT_MF16C
-- Performing Test COMPILER_SUPPORT_MF16C - Success
-- Performing Test COMPILER_SUPPORT_FMA
-- Performing Test COMPILER_SUPPORT_FMA - Success
-- Performing Test COMPILER_SUPPORT_AVX
-- Performing Test COMPILER_SUPPORT_AVX - Success
-- Performing Test onnxruntime_HAVE_BUILTIN_ATOMICS
-- Performing Test onnxruntime_HAVE_BUILTIN_ATOMICS - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: built in to C library  
-- Found Patch: /usr/bin/patch  
Patch found: /usr/bin/patch
-- Found Python: /usr/local/bin/python3 (found suitable version "3.9.18", minimum required is "3.8") found components: Interpreter 
Loading Dependencies URLs ...
Loading Dependencies ...
-- Populating abseil_cpp
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-subbuild
[ 11%] Creating directories for 'abseil_cpp-populate'
[ 22%] Performing download step (download, verify and extract) for 'abseil_cpp-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-subbuild/abseil_cpp-populate-prefix/src/20230802.0.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-subbuild/abseil_cpp-populate-prefix/src/20230802.0.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-subbuild/abseil_cpp-populate-prefix/src/20230802.0.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'abseil_cpp-populate'
[ 44%] No patch step for 'abseil_cpp-populate'
[ 55%] No configure step for 'abseil_cpp-populate'
[ 66%] No build step for 'abseil_cpp-populate'
[ 77%] No install step for 'abseil_cpp-populate'
[ 88%] No test step for 'abseil_cpp-populate'
[100%] Completed 'abseil_cpp-populate'
[100%] Built target abseil_cpp-populate
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Success
-- Abseil source dir:/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/abseil_cpp-src
-- Populating date
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/date-subbuild
[ 11%] Creating directories for 'date-populate'
[ 22%] Performing download step (download, verify and extract) for 'date-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/date-subbuild/date-populate-prefix/src/v3.0.1.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/date-subbuild/date-populate-prefix/src/v3.0.1.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/date-subbuild/date-populate-prefix/src/v3.0.1.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/date-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'date-populate'
[ 44%] No patch step for 'date-populate'
[ 55%] No configure step for 'date-populate'
[ 66%] No build step for 'date-populate'
[ 77%] No install step for 'date-populate'
[ 88%] No test step for 'date-populate'
[100%] Completed 'date-populate'
[100%] Built target date-populate
# date: USE_SYSTEM_TZ_DB ON
# date: MANUAL_TZ_DB OFF
# date: USE_TZ_DB_IN_DOT OFF
# date: BUILD_SHARED_LIBS OFF
# date: ENABLE_DATE_TESTING OFF
# date: DISABLE_STRING_VIEW OFF
CMake Warning at external/onnxruntime_external_deps.cmake:265 (message):
  Target processor architecture "amd64" is not supported in cpuinfo.  cpuinfo
  not included.
Call Stack (most recent call first):
  CMakeLists.txt:557 (include)


-- Populating google_nsync
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/google_nsync-subbuild
[ 11%] Creating directories for 'google_nsync-populate'
[ 22%] Performing download step (download, verify and extract) for 'google_nsync-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/google_nsync-subbuild/google_nsync-populate-prefix/src/1.26.0.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/google/nsync/archive/refs/tags/1.26.0.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/google_nsync-subbuild/google_nsync-populate-prefix/src/1.26.0.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/google_nsync-subbuild/google_nsync-populate-prefix/src/1.26.0.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/google_nsync-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'google_nsync-populate'
[ 44%] No patch step for 'google_nsync-populate'
[ 55%] No configure step for 'google_nsync-populate'
[ 66%] No build step for 'google_nsync-populate'
[ 77%] No install step for 'google_nsync-populate'
[ 88%] No test step for 'google_nsync-populate'
[100%] Completed 'google_nsync-populate'
[100%] Built target google_nsync-populate
-- Populating safeint
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/safeint-subbuild
[ 11%] Creating directories for 'safeint-populate'
[ 22%] Performing download step (download, verify and extract) for 'safeint-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/safeint-subbuild/safeint-populate-prefix/src/3.0.28.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/dcleblanc/SafeInt/archive/refs/tags/3.0.28.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/safeint-subbuild/safeint-populate-prefix/src/3.0.28.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/safeint-subbuild/safeint-populate-prefix/src/3.0.28.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/safeint-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'safeint-populate'
[ 44%] No patch step for 'safeint-populate'
[ 55%] No configure step for 'safeint-populate'
[ 66%] No build step for 'safeint-populate'
[ 77%] No install step for 'safeint-populate'
[ 88%] No test step for 'safeint-populate'
[100%] Completed 'safeint-populate'
[100%] Built target safeint-populate
-- Populating utf8_range
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/utf8_range-subbuild
[ 11%] Creating directories for 'utf8_range-populate'
[ 22%] Performing download step (download, verify and extract) for 'utf8_range-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/utf8_range-subbuild/utf8_range-populate-prefix/src/72c943dea2b9240cd09efde15191e144bc7c7d38.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/protocolbuffers/utf8_range/archive/72c943dea2b9240cd09efde15191e144bc7c7d38.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/utf8_range-subbuild/utf8_range-populate-prefix/src/72c943dea2b9240cd09efde15191e144bc7c7d38.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/utf8_range-subbuild/utf8_range-populate-prefix/src/72c943dea2b9240cd09efde15191e144bc7c7d38.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/utf8_range-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'utf8_range-populate'
[ 44%] No patch step for 'utf8_range-populate'
[ 55%] No configure step for 'utf8_range-populate'
[ 66%] No build step for 'utf8_range-populate'
[ 77%] No install step for 'utf8_range-populate'
[ 88%] No test step for 'utf8_range-populate'
[100%] Completed 'utf8_range-populate'
[100%] Built target utf8_range-populate
-- Populating protobuf
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/protobuf-subbuild
[ 11%] Creating directories for 'protobuf-populate'
[ 22%] Performing download step (download, verify and extract) for 'protobuf-populate'
-- Downloading...
   dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/protobuf-subbuild/protobuf-populate-prefix/src/v21.12.zip'
   timeout='none'
   inactivity timeout='none'
-- Using src='https://github.com/protocolbuffers/protobuf/archive/refs/tags/v21.12.zip'
-- verifying file...
       file='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/protobuf-subbuild/protobuf-populate-prefix/src/v21.12.zip'
-- Downloading... done
-- extracting...
     src='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/protobuf-subbuild/protobuf-populate-prefix/src/v21.12.zip'
     dst='/root/Download/onnxruntime/build/linux/RelWithDebInfo/_deps/protobuf-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 33%] No update step for 'protobuf-populate'
[ 44%] Performing patch step for 'protobuf-populate'
patch: unrecognized option `--binary'
usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]
             [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]
             [-r rej-name] [-V t | nil | never | none] [-x number]
             [-z backup-ext] [--posix] [origfile [patchfile]]
       patch <patchfile
gmake[2]: *** [CMakeFiles/protobuf-populate.dir/build.make:117: protobuf-populate-prefix/src/protobuf-populate-stamp/protobuf-populate-patch] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/protobuf-populate.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
CMake Error at /usr/local/share/cmake/Modules/FetchContent.cmake:1622 (message):
  Build step for protobuf failed: 2
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FetchContent.cmake:1762:EVAL:2 (__FetchContent_directPopulate)
  /usr/local/share/cmake/Modules/FetchContent.cmake:1762 (cmake_language)
  external/helper_functions.cmake:139 (FetchContent_Populate)
  external/onnxruntime_external_deps.cmake:361 (onnxruntime_fetchcontent_makeavailable)
  CMakeLists.txt:557 (include)


-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
  File "/root/Download/onnxruntime/tools/ci_build/build.py", line 2697, in <module>
    sys.exit(main())
  File "/root/Download/onnxruntime/tools/ci_build/build.py", line 2555, in main
    generate_build_tree(
  File "/root/Download/onnxruntime/tools/ci_build/build.py", line 1425, in generate_build_tree
    run_subprocess(
  File "/root/Download/onnxruntime/tools/ci_build/build.py", line 800, in run_subprocess
    return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env)
  File "/root/Download/onnxruntime/tools/python/util/run.py", line 49, in run
    completed_process = subprocess.run(
  File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '/root/Download/onnxruntime/cmake', '--compile-no-warning-as-error', '-Donnxruntime_RUN_ONNX_TESTS=OFF', '-Donnxi

Visual Studio Version

No response

GCC / Compiler Version

FreeBSD clang version 14.0.5

@bootkernel bootkernel added the build build issues; typically submitted using template label Nov 4, 2023
@github-actions github-actions bot added the platform:mobile issues related to ONNX Runtime mobile; typically submitted using template label Nov 4, 2023
@skottmckay skottmckay removed the platform:mobile issues related to ONNX Runtime mobile; typically submitted using template label Nov 7, 2023
@skottmckay
Copy link
Contributor

AFAIK FreeBSD is not a directly supported platform.

Seems like it's an issue with the version of patch you have. Maybe you can install a different version that supports the missing flag and check that cmake can find that.

patch: unrecognized option --binary'`

@skottmckay
Copy link
Contributor

skottmckay commented Nov 7, 2023

Based on this you may need to install GNU patch: cweagans/composer-patches#159 (comment)

GNU patch source showing the --binary option

https://git.savannah.gnu.org/cgit/patch.git/tree/src/patch.c#n781

@bootkernel
Copy link
Author

Based on this you may need to install GNU patch: cweagans/composer-patches#159 (comment)

GNU patch source showing the --binary option

https://git.savannah.gnu.org/cgit/patch.git/tree/src/patch.c#n781

Thanks a lot, it worked! Building it, let's see if I run into any other issues.

@snnn snnn closed this as completed Nov 14, 2023
@Vringe
Copy link

Vringe commented Apr 26, 2024

There is a cleaner way: Just add the line:

set(Patch_EXECUTABLE "/usr/local/bin/gpatch")

to cmake/CMakeLists.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

4 participants