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

getpeername/getnameinfo not detected by configure test #9154

Closed
Beuc opened this issue Aug 5, 2019 · 4 comments · Fixed by #9158

Comments

@Beuc
Copy link
Contributor

commented Aug 5, 2019

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

@kripken

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

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?

@Beuc

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2019

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
@kripken

This comment has been minimized.

Copy link
Member

commented Aug 6, 2019

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.

@Beuc

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2019

Looks like it works, thanks!

@kripken kripken closed this in #9158 Aug 9, 2019

kripken added a commit that referenced this issue Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.