Skip to content

[BUG]: hardcoded linker flag -nostdlib prevents security hardening #60

@lahwaacz

Description

@lahwaacz

Version

1.0.1

Version

13.1.1

Which installation method(s) does this occur on?

Source

Describe the bug.

cutile specifies the -nostdlib flag for linking the C extension:

set(nostdlib_flags -nostdlib -DNDEBUG -fno-builtin)

However, this flag conflicts with some security hardening options such as -fstack-clash-protection, leading to errors like

/usr/bin/c++ -fPIC -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/python-cuda-tile/src=/usr/src/debug/python-cuda-tile -flto=auto -O3 -DNDEBUG -shared -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now          -Wl,-z,pack-relative-relocs -flto=auto -fno-exceptions -fno-rtti -fPIC -fvisibility=hidden -nostdlib -DNDEBUG -fno-builtin -Wl,--no-undefined -Wl,--dependency-file=CMakeFiles/_cext_shared.dir/link.d -Wl,-soname,lib_cext_shared.so -o lib_cext_shared.so CMakeFiles/_cext_shared.dir/module.cpp.o  lib_cext_static.a /usr/lib/libpython3.14.so
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o: in function `get_cuda_error(cudaError_enum)':
/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/cuda_helper.cpp:13:(.text+0x4e): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o: in function `try_getattr(_object*, char const*, SavedException*) [clone .constprop.0]':
/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/py.h:215:(.text+0x218): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o: in function `try_get_torch_globals()':
/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/tile_kernel.cpp:1721:(.text+0x9dd): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o: in function `(anonymous namespace)::do_get_proc_address(cudaError_enum (*)(char const*, void**, int, unsigned long, CUdriverProcAddressQueryResult_enum*), char const*, int)':
/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/cuda_loader.cpp:36:(.text+0xa87): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o: in function `get_compute_capability(_object*, _object*)':
/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/cuda_helper.cpp:64:(.text+0xba2): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccWD7NDr.ltrans0.ltrans.o:/usr/src/debug/python-cuda-tile/cutile-python-1.0.1/cext/cuda_helper.cpp:75: more undefined references to `__stack_chk_fail' follow
collect2: error: ld returned 1 exit status

Why do you need the -nostdlib flag? Removing it would allow building cutile from source with CFLAGS used by official Arch Linux packages.

Minimum reproducible example

Relevant log output

Full env printout

Other/Misc.

No response

Contributing Guidelines

  • I agree to follow cuTile Python's contributing guidelines
  • I have searched the open bugs and have found no duplicates for this bug report

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions