Open luislavena opened 2 years ago
I object to @HertzDevil's comment https://github.com/crystal-lang/crystal/pull/11876#issuecomment-1061873648
If we simply rename the libs in
src/lib_c/*/iconv.cr
toLibIconv
then that meanssrc/lib_c
will no longer contain system library bindings exclusively.
Renaming the lib type in these files changes nothing about the target of these bindings. They still refer to the same system library symbols.
Maybe a minor argument could be made about defining system library bindings on a lib type named LibIconv
when that's usually LibC
. But really, it's just names. Internal names 🤷
The system library bindings for iconv
mimic the libiconv
API, so I think it's fine to use the name of that library for the lib type.
They still refer to the same system library symbols
Not if use_libiconv
is defined, because as I said, libiconv
is not a system library to begin with. I believe src/lib_c
should not have the possibility of containing non-system bindings even if they are only enabled by a compile-time flag.
The system library bindings for
iconv
mimic thelibiconv
API
libiconv
mimics the POSIX iconv
API, not the other way round.
Not if
use_libiconv
is defined
The purpose of use_libiconv
is not to use the bindings in src/lib_c/*/iconv.cr
. The bindings to libiconv
wouldn't be in src/lib_c
, of course.
This would be the require code for iconv with https://github.com/crystal-lang/crystal/pull/11876 and this issue resolved:
{% if flag?(:use_libiconv) || flag?(:win32) %}
require "./lib_iconv"
{% else %}
require "c/iconv"
{% end %}
What would this look like if we reuse the Regex::Engine
idiom here?
This is a recap of a side conversation started in #11876:
@asterite commented:
Followed by this comment:
And confirmation from @HertzDevil in this comment:
I think what @asterite was suggesting is really remove all
lib_c/*/c/iconv.cr
and get everything unified inlib_iconv.cr
. Except for certain platforms (mentioned before), they all share the same Lib interface definition.Then the only difference if is that is exposed by the libc of that platform or not (Eg musl iconv vs having libiconv explicit linked).
Still not sure the best approach on this (not fully grasped all the needed changes), so decided to move this out of the PR so we can keep track of all the comments.
Thank you! ❤️ ❤️ ❤️