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

make fails on osx arm64 #7

Closed
sevenb23 opened this issue Apr 13, 2023 · 4 comments
Closed

make fails on osx arm64 #7

sevenb23 opened this issue Apr 13, 2023 · 4 comments

Comments

@sevenb23
Copy link

sevenb23 commented Apr 13, 2023

I'm trying to install on the below arm64-apple-darwin22.1.0. make stage breaks with the following error

Undefined symbols for architecture arm64:
  "libyang::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, libyang::NodeType const&)", referenced from:
      doctest::detail::filldata<libyang::NodeType>::fill(std::__1::basic_ostream<char, std::__1::char_traits<char> >*, libyang::NodeType const&) in schema_node.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test_schema_node] Error 1
make[1]: *** [CMakeFiles/test_schema_node.dir/all] Error 2
make: *** [all] Error 2

Is the platform not supported ?
compiler : Apple clang version 14.0.0 (clang-1400.0.29.202)

@syyyr
Copy link
Contributor

syyyr commented Apr 13, 2023

It could have something to do with these lines:
https://github.com/CESNET/libyang-cpp/blob/master/include/libyang-cpp/Enum.hpp#L295-L302

std::ostream& operator<<(std::ostream& os, const NodeType& type)
#if defined(__GNUC__) && !defined(__llvm__) && __GNUC__ <= 10
    LIBYANG_CPP_EXPORT
#endif
    ;
std::ostream& operator<<(std::ostream& os, const ErrorCode& err)
#if defined(__GNUC__) && !defined(__llvm__) && __GNUC__ <= 10
    LIBYANG_CPP_EXPORT
#endif
    ;

I'm not sure if apple arm needs the LIBYANG_CPP_EXPORT macro or not. Although if you're using clang, then __llvm__ is surely defined? So maybe LIBYANG_CPP_EXPORT is needed after all? Unfortunately, I don't have an Apple arm device to test this.

@jktjkt
Copy link
Contributor

jktjkt commented Apr 13, 2023

I got a similar error when building via GitHub CI with GCC 11.3 on OS X 13 (targetting 12.4), but this time for x86_64. I.e., a different compiler, and a different architecture:

FAILED: test_schema_node 
: && /usr/local/bin/g++-11 -Wall -Wextra -pedantic -Woverloaded-virtual -Wimplicit-fallthrough -Wsuggest-override  -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.4 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/test_schema_node.dir/tests/schema_node.cpp.o -o test_schema_node  -Wl,-rpath,/Users/runner/work/oopt-gnpy-libyang/build-libyang-cpp  libDoctestIntegration.a  libyang-cpp.dylib && :
Undefined symbols for architecture x86_64:
  "__ZN7libyanglsERSoRKNS_8NodeTypeE", referenced from:
      __ZN7doctest6detail19stringifyBinaryExprIN7libyang8NodeTypeES3_EENS_6StringERKT_PKcRKT0_ in schema_node.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

I'll take a look into this.

@jktjkt
Copy link
Contributor

jktjkt commented Apr 13, 2023

@sevenb23 , does this patch work for you?

jktjkt added a commit that referenced this issue Apr 14, 2023
Turns out that this macro is needed also on Mac OS X builds (both with
GCC 11.3 for x86_64 and with Apple clang version 14.0.0
(clang-1400.0.29.202) for arm64-apple-darwin22.1.0). If I'm reading my
original commit message correctly, this was only choking on MSVC, so
let's use that macro everywhere but on MSVC.

Fixes: 1d7c822 Make this buildable on Ubuntu 20.04 with GCC 10
Bug: #7
Change-Id: Ib3502057d17ab8d4a138de02204d0b8e1e1c6442
@jktjkt
Copy link
Contributor

jktjkt commented Apr 14, 2023

Fixed via 510d5ac

@jktjkt jktjkt closed this as completed Apr 14, 2023
jktjkt pushed a commit that referenced this issue Sep 6, 2024
There is ODR violation in libyang tests reported by ASan which breaks
our CI builds. This commit temporarily (until this gets solved in
upstream) pins the libyang version to 3.0.18 which builds just fine.

The log from ASan:

  52/60 Test #31: utest_plugins .....................***Failed    1.22 sec
  [==========] tests: Running 4 test(s).
  [ RUN      ] test_add_invalid
  [       OK ] test_add_invalid
  [ RUN      ] test_add_simple
  =================================================================
  ==2826==ERROR: AddressSanitizer: odr-violation (0x7f6d170dcb40):
    [1] size=24 'ly_version_so' /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/src/ly_common.c:43
    [2] size=24 'ly_version_so' /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/src/ly_common.c:43
  These globals were registered at these points:
    [1]:
      #0 0x437ffa in __asan_register_globals (/home/ci/build/github/CESNET/libyang/tests/utest_plugins+0x437ffa) (BuildId: e79d14f37e59b6533b66d19363b25fea9e324edb)
      #1 0x7f6d16691b9e in asan.module_ctor ly_common.c
      #2 0x7f6d1aad7236 in call_init /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-init.c:74:3
      #3 0x7f6d1aad7236 in call_init /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-init.c:26:1
      #4 0x7f6d1aad732c in _dl_init /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-init.c:121:5
      #5 0x7f6d1aad35c1 in _dl_catch_exception /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-catch.c:211:7
      #6 0x7f6d1aaddeeb in dl_open_worker /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-open.c:827:5
      #7 0x7f6d1aad3522 in _dl_catch_exception /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-catch.c:237:8
      #8 0x7f6d1aade2e3 in _dl_open /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-open.c:903:17
      #9 0x7f6d1a7b5713 in dlopen_doit /usr/src/debug/glibc-2.37-18.fc38.x86_64/dlfcn/dlopen.c:56:15
      #10 0x7f6d1aad3522 in _dl_catch_exception /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-catch.c:237:8
      #11 0x7f6d1aad3678 in _dl_catch_error /usr/src/debug/glibc-2.37-18.fc38.x86_64/elf/dl-catch.c:256:19
      #12 0x7f6d1a7b51f2 in _dlerror_run /usr/src/debug/glibc-2.37-18.fc38.x86_64/dlfcn/dlerror.c:138:17
      #13 0x7f6d1a7b57ce  /usr/src/debug/glibc-2.37-18.fc38.x86_64/dlfcn/dlopen.c:71:10
      #14 0x7f6d1a7b57ce in dlopen@@GLIBC_2.34 /usr/src/debug/glibc-2.37-18.fc38.x86_64/dlfcn/dlopen.c:81:12
      #15 0x485f82 in dlopen (/home/ci/build/github/CESNET/libyang/tests/utest_plugins+0x485f82) (BuildId: e79d14f37e59b6533b66d19363b25fea9e324edb)
      #16 0xcb5ee3 in plugins_load_module /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/src/plugins.c:378:17
      #17 0xcb5e67 in lyplg_add /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/src/plugins.c:589:11
      #18 0xea2a60 in test_add_simple /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/tests/utests/basic/test_plugins.c:50:5
      #19 0x7f6d1aac218f  (/lib64/libcmocka.so.0+0x618f) (BuildId: 785844a0941c0bde763740a981d056f60aa9c7b7)
      #20 0x7f6d1aac2904 in _cmocka_run_group_tests (/lib64/libcmocka.so.0+0x6904) (BuildId: 785844a0941c0bde763740a981d056f60aa9c7b7)
      #21 0xea21a2 in main /home/ci/src/cesnet-gerrit-public/github/CESNET/libyang/tests/utests/basic/test_plugins.c:152:12

Change-Id: Id8a4771296d2e85de2ec29fbd17046d280d2eda2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants