Skip to content

Library symbols added DEFAULT_LIBRARY_FUNCS_TO_INCLUDE don't pull in their native dependencies. #19759

Closed

Description

@sbc100

When the native code itself depends on a library function the stub object that we pass to the linker allows the linker to know which symbols it needs to export.

However if we simply add the symbol DEFAULT_LIBRARY_FUNCS_TO_INCLUDE the linker has no visibility of this.

e.g.

$ ./emcc ~/test/hello.c -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=gethostbyname_r 
error: undefined symbol: malloc (referenced by $getHostByName, referenced by gethostbyname, referenced by gethostbyname_r, referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _malloc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: htons (referenced by $inetPton6, referenced by $DNS, referenced by $getHostByName, referenced by gethostbyname, referenced by gethostbyname_r, referenced by root reference (e.g. compiled C/C++ code))
warning: _htons may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: memcpy (referenced by gethostbyname_r, referenced by root reference (e.g. compiled C/C++ code))
warning: _memcpy may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: free (referenced by gethostbyname_r, referenced by root reference (e.g. compiled C/C++ code))
warning: _free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/usr/local/google/home/sbc/dev/wasm/emsdk/node/16.20.0_64bit/bin/node /usr/local/google/home/sbc/dev/wasm/emscripten/src/compiler.js /tmp/tmp5ae7rmz_.json' failed (returned 1)

Activity

  1. added a commit that references this issue on Jul 12, 2023
    b3ba4d7
  2. assigned and unassigned on Jul 12, 2023
  3. added 5 commits that reference this issue on Jul 12, 2023
    04bb728
    7a2cd88
    e5a5d4b
    012ca58
    e71ee98
  4. added a commit that references this issue on Jul 12, 2023
    f2fc713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions