Skip to content

getpeername/getnameinfo not detected by configure test #9154

Closed

Description

@Beuc

Hi,

While compiling Python's _socket module, I noticed that getpeername and getnameinfo were mistakenly detected as not present.

Something appears to confuse emscripten in the configuration test, as it returns a link error with htons:

$ emcc -o conftest    conftest.c -ldl
warning: unexpected number of arguments 0 in call to 'getpeername', should be 3
error: undefined symbol: htons
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
Error: Aborting compilation due to previous errors

(using -s ERROR_ON_UNDEFINED_SYMBOLS=0 as suggested would defeat the point of the config test :))

The behavior is triggered by using conftest.c as a file name.
It happens even without all the autoconf boilerplate.

See testcases attached.
conftests.zip

Activity

  1. kripken commented on Aug 5, 2019

    @kripken
    Member

    Thanks @Beuc! Fix in #9158

    I see the same behavior regardless of the filename, though, it doesn't seem specific to conftest.c. Maybe I'm missing something? Does the PR work for you?

  2. Beuc commented on Aug 5, 2019

    @Beuc
    ContributorAuthor

    Here's what I had with emsdk latest:

    $ mv conftest.c conftest-getnameinfo.c
    $ emcc -o conftest-getnameinfo    conftest-getnameinfo.c -ldl
    [OK]
    

    Since Emscripten has working test cases against getpeername/getnameinfo I thought this was specific to conftest.c. But admittedly this failed too :)

    $ emcc -o conftest-getnameinfo.js    conftest-getnameinfo.c -ldl; echo $?
    warning: unexpected number of arguments 0 in call to 'getnameinfo', should be 1
    error: undefined symbol: htons
    warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
    Error: Aborting compilation due to previous errors
    

    The PR appears to work (correct results from Python ./configure) however there's still an error at runtime:

    $ emcc -o conftest-getnameinfo.js    conftest-getnameinfo.c -ldl
    warning: unexpected number of arguments 0 in call to 'getnameinfo', should be 1
    $ node conftest-getnameinfo.js
    exception thrown: ReferenceError: _ntohs is not defined,ReferenceError: _ntohs is not defined
    
  3. kripken commented on Aug 6, 2019

    @kripken
    Member

    Thanks, yeah, some more deps were needed, I added those now.

    In general the sockets code is not well tested - just not many people use it, and our test suite is very minimal there.

  4. Beuc commented on Aug 6, 2019

    @Beuc
    ContributorAuthor

    Looks like it works, thanks!

  5. added a commit that references this issue on Aug 9, 2019
    9c317db
  6. added a commit that references this issue on Dec 23, 2020
    99b7436
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