awslabs / aws-c-io

This is a module for the AWS SDK for C. It handles all IO and TLS work for application protocols.
Apache License 2.0
109 stars 61 forks source link

Intel VTune linker errors #615

Closed deej-io closed 8 months ago

deej-io commented 9 months ago

Describe the bug

I am currently using a few AWS C++ libraries that use this library transitively via CMake FetchContent and a recent commit has introduced linker errors for Intel VTune symbols.

Intel VTune should be an optional dependency with a CMake option to enable it.

Expected Behavior

Library should compile and link successfully.

Current Behavior

Library fails with link errors if Intel VTune is not installed as a system dependency:

/bin/ld: ../../../_deps/aws-chime-sdk-build/crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(epoll_event_loop.c.o): in function `aws_event_loop_thread':
/home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:620: undefined reference to `__itt_task_begin_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:651: undefined reference to `__itt_task_begin_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:653: undefined reference to `__itt_task_end_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:656: undefined reference to `__itt_task_end_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:665: undefined reference to `__itt_task_begin_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:667: undefined reference to `__itt_task_end_ptr__3_0'
/bin/ld: ../../../_deps/aws-chime-sdk-build/crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(stream.c.o): in function `aws_input_stream_read':
/home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:36: undefined reference to `__itt_task_begin_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:38: undefined reference to `__itt_task_end_ptr__3_0'
/bin/ld: ../../../_deps/aws-chime-sdk-build/crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(tracing.c.o): in function `aws_io_tracing_init':
/home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:15: undefined reference to `__itt_domain_create_ptr__3_0'
/bin/ld: /home/djr/dev/project/build/_deps/aws-chime-sdk-src/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:16: undefined reference to `__itt_string_handle_create_ptr__3_0'
collect2: error: ld returned 1 exit status

Reproduction Steps

Create a CMake project. Add aws-c-io as a dependency using FetchContent Build the project.

Possible Solution

The commit that introduced the issue should be reverted to allow the project to continue to build. It can then be re-introduced with a CMake option to enable VTune

Additional Information/Context

No response

aws-c-io version used

v0.14.0

Compiler and version used

g++ (GCC) 13.2.1 20230801

Operating System and version

Arch Linux (6.6.6-arch1-1)

waahm7 commented 9 months ago

Are you using the latest version of aws-c-common? Aws-c-common defines a macro which strips out intel vtune unless enabled https://github.com/awslabs/aws-c-common/pull/1050/files#diff-9b6ea2bf68ed273a9e82a3ef8e0b10a0b3105c67f71719cc879d27c0bcce8dafR254.

deej-io commented 9 months ago

Thank you for the pointer.

This library is included in my project through the dependency chain aws-chime-sdk -> aws-crt-cpp -> aws-c-io. I am using the latest version of aws-crt-cpp, which seems to have the version of aws-c-common library which has the cmake option to #define out the vtune symbols as a submodule.

If I checkout the latest version of aws-crt-cpp and compile it, I get the same linker errors when it tries to build the tests.

It seems that, for some reason, the -DINTEL_NO_ITTNOTIFY_API is not being set even though tracing is not enable from that project. I'm not sure which library is at fault here, aws-c-common or aws-c-common, but it seems to be one of those rather than this repo. I'll close the PR.