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

libnvidia_container fails to compile with mold #226

Open
wallentx opened this issue Oct 20, 2023 · 3 comments
Open

libnvidia_container fails to compile with mold #226

wallentx opened this issue Oct 20, 2023 · 3 comments

Comments

@wallentx
Copy link

wallentx commented Oct 20, 2023

On Arch I have mold configured as my default linker. Attempting to build this results in unknown linker script token in reference to https://github.com/NVIDIA/libnvidia-container/blob/main/src/libnvidia-container.lds

I found a discussion in the mold project where I had learned that the SECTIONS linker script command had intentionally been left out. I pointed out that the libnvidia-container project was failing to build, and the maintainer advised a workaround, which might be appropriate to implement here.

Please see the conversation here:
rui314/mold#243 (comment)

@rui314
Copy link

rui314 commented Dec 13, 2023

I didn't try to build libnvidia-container myself, but it seems the use of linker script is not necessary.

You can specify an entry point function with -Wl,-e,nvc_entrypoint instead of the ENTRY linker script directive.

It seems the SECTIONS directive didn't serve any purpose. The intention of the directive seems to place .note.ABI-tag at the begininng of an output file, but the linker does so by default. You probably can just remove it.

Then move the VERSION contents to a new file, say, libnvidia-container.ver and then pass that filename with -Wl,--version-script,libnvidia-container.ver.

libnvidia-container.ver's contents would be the following.

NVC_1.0 {
    global:
        nvc_version;
        nvc_context_new;
        nvc_context_free;
        nvc_config_new;
        nvc_config_free;
        nvc_init;
        nvc_shutdown;
        nvc_error;
        nvc_ldcache_update;
        nvc_container_config_new;
        nvc_container_config_free;
        nvc_container_new;
        nvc_container_free;
        nvc_driver_info_new;
        nvc_driver_info_free;
        nvc_device_info_new;
        nvc_device_info_free;
        nvc_driver_mount;
        nvc_device_mount;
        nvc_nvcaps_style;
        nvc_nvcaps_device_from_proc_path;
        nvc_mig_device_access_caps_mount;
        nvc_mig_config_global_caps_mount;
        nvc_mig_monitor_global_caps_mount;
        nvc_device_mig_caps_mount;

        __ubsan_default_options;
    local:
        *;
};

With that, I believe you can remove the linker script.

@enihcam
Copy link

enihcam commented Feb 11, 2024

Same issue here:

At top level:                                                                                                                                        
cc1: note: unrecognized command-line option ‘-Wno-gnu-alignof-expression’ may have been intended to silence earlier diagnostics                      
cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics                      
ar: creating libnvidia-container.a                                                                                                                   
a - /tmp/makepkg/libnvidia-container/src/libnvidia-container/src/libnvidia-container.lo                                                              
mold: fatal: /tmp/makepkg/libnvidia-container/src/libnvidia-container/src/libnvidia-container.lds:1: ENTRY(nvc_entrypoint)                           
                                                                                              ^ unknown linker script token
collect2: error: ld returned 1 exit status
make: *** [Makefile:222: libnvidia-container.so.1.14.4] Error 1
make: *** Waiting for unfinished jobs....

@rui314
Copy link

rui314 commented Feb 17, 2024

Yes, because nothing has changed in the upstream.

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