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

alignment of atom errors on mac os X 14.5 ? #56

Open
ec-ecss opened this issue Jul 16, 2024 · 3 comments
Open

alignment of atom errors on mac os X 14.5 ? #56

ec-ecss opened this issue Jul 16, 2024 · 3 comments

Comments

@ec-ecss
Copy link
Contributor

ec-ecss commented Jul 16, 2024

Hello. Can't manage to make it build since a mac os X update

makefile

cmake_minimum_required(VERSION 3.14)
set(BIN athena_core)
project(athena_core C)

enable_testing()

set(TEST_SOURCES tests/test_core.c)
add_executable(athena_core_test ${TEST_SOURCES})
add_test(NAME athena_core_test COMMAND athena_core_test)

target_link_libraries(athena_core_test athena_core)

set(SOURCES
        casts.c
        ath_ticker.c strings.c uint128.c threads.c arrays.c)
add_library(${BIN} ${SOURCES})

test file

#include <stdlib.h>

#define CTEST_MAIN 1

#include "../../../vendor/ctest/ctest.h"

#include "../include/core.h"

int main(int argc, const char **argv) {
    return ctest_main(argc, argv);
}

CTEST(suite, test1) {
    ath_uint128 val;
    val.l = 0xAAAAAAAAAAAAAAAA; 
    val.r = 0x5555555555555555;  
    ath_core_uint128_shiftleft(&val, 0);
    ASSERT_EQUAL(val.l , 0xAAAAAAAAAAAAAAAA);
}

Result of build

====================[ Build | all | Debug ]=====================================
/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --build /Volumes/fswork/www/athena/src/athena_core/cmake-build-debug --target all -j 6
[2/2] Linking C executable athena_core_test
FAILED: athena_core_test 
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/athena_core_test.dir/tests/test_core.c.o -o athena_core_test  libathena_core.a && :
ld: warning: alignment (1) of atom '_ctest_suite_test' from '/Volumes/fswork/www/athena/src/athena_core/cmake-build-debug/CMakeFiles/athena_core_test.dir/tests/test_core.c.o' is too small and may result in unaligned pointers 
ld: warning: alignment (1) of atom '_ctest_suite_test1' from '/Volumes/fswork/www/athena/src/athena_core/cmake-build-debug/CMakeFiles/athena_core_test.dir/tests/test_core.c.o' is too small and may result in unaligned pointers 
ld: building fixups: pointer not aligned at _ctest_suite_test+0x0 from /Volumes/fswork/www/athena/src/athena_core/cmake-build-debug/CMakeFiles/athena_core_test.dir/tests/test_core.c.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
@bvdberg
Copy link
Owner

bvdberg commented Jul 16, 2024

I cannot test that version myself (I only have a MacBook Pro with older Mac OS). Maybe you could
try to modify the following in ctest.h:

line 92:
#ifdef APPLE
#define CTEST_IMPL_SECTION attribute ((used, section ("__DATA, .ctest"), aligned(1)))
#else

Change the aligned(1) into align(8)

Otherwise, could you set the pre-processed code? (gcc -E)

@ec-ecss
Copy link
Contributor Author

ec-ecss commented Jul 16, 2024

It's ok with align(8) !
Do you want me to do a PR ?

@bvdberg
Copy link
Owner

bvdberg commented Jul 16, 2024 via email

ec-ecss added a commit to ec-ecss/ctest that referenced this issue Jul 16, 2024
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

2 participants