Thread overview
[Issue 23793] std.stdio.openNetwork should be refactored and moved to a different place
Mar 18, 2023
Witold Baryluk
Mar 18, 2023
Adam D. Ruppe
Mar 18, 2023
Witold Baryluk
Mar 18, 2023
Witold Baryluk
Mar 18, 2023
Adam D. Ruppe
Mar 18, 2023
Witold Baryluk
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

Witold Baryluk <witold.baryluk+d@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

--- Comment #1 from Adam D. Ruppe <destructionator@gmail.com> ---
If you just delete it, what improvements to do you see on import speed and linking compatibility?

--
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

--- Comment #2 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
> If you just delete it, what improvements to do you see on import speed and linking compatibility?

In terms of speed.

It appears essentially none actually.

The reason is that all the transitive imports are done inside `std.stdio.openNetwork`, and D compiler does not import them, unless it needs to compile `openNetwork` function itself. But this function is already compiled as part of Phobos, so compiler just uses it, with doing semantic or codegen on this function. Still it needs to read `stdio.d` with it. Not a lot.

In terms of compatibility, it was working before, now with this function present, I get things like this:

/build/gcc-12-bTRWOB/gcc-12-12.2.0/build/x86_64-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/stdio.d:5860:
warning: Using 'gethostbyname' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking


Even if this was not the case, I think it is worth moving `openNetwork` somewhere else.

--
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

--- Comment #3 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
Even more comical. `gethostbyname` is deprecated function, even removed from POSIX.1-2008. And it is multi thread unsafe!

In my opinion one D should use own resolver (like Go) on Unix by default, and not use C for this, but that is longer project.

--
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

--- Comment #4 from Adam D. Ruppe <destructionator@gmail.com> ---
> The reason is that all the transitive imports are done inside `std.stdio.openNetwork`, and D compiler does not import them, unless it needs to compile `openNetwork` function itself.

That's not true for normal functions, only templates.

> In terms of compatibility, it was working before, now with this function present, I get things like this:

This function was added 13 years ago and barely changed since then, so how long ago are you looking?

--
March 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23793

--- Comment #5 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
> This function was added 13 years ago and barely changed since then, so how long ago are you looking?

You are right. I only noticed this function in std.stdio about a month or two ago.

But I did not have issue with static linking in the past, so maybe something else changed, i.e. gdc.

--