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

encoding.iconv: unable to find includes and lib on OpenBSD #23573

Closed
lcheylus opened this issue Jan 25, 2025 · 1 comment · Fixed by #23575
Closed

encoding.iconv: unable to find includes and lib on OpenBSD #23573

lcheylus opened this issue Jan 25, 2025 · 1 comment · Fixed by #23575
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@lcheylus
Copy link
Contributor

lcheylus commented Jan 25, 2025

Bug description

On OpenBSD current/amd64, tests for vlib/encoding/iconv/ fail because the compiler is unable to find iconv includes (iconv.h) or library.

Same issue with tcc, gcc and clang.

Reproduction Steps

On OpenBSD current/amd64, iconv library is installed via libiconv (latest version = 1.17) package (pkg_add iconv).

Contents of iconv package with includes and library

pkg_info -L libiconv
Information for inst:libiconv-1.17

Files:
/usr/local/bin/iconv
/usr/local/include/iconv.h
/usr/local/include/libcharset.h
/usr/local/include/localcharset.h
/usr/local/lib/libcharset.a
/usr/local/lib/libcharset.la
/usr/local/lib/libcharset.so.1.1
/usr/local/lib/libiconv.a
/usr/local/lib/libiconv.la
/usr/local/lib/libiconv.so.7.1
/usr/local/man/man1/iconv.1
/usr/local/man/man3/iconv.3
/usr/local/man/man3/iconv_close.3
/usr/local/man/man3/iconv_open.3
/usr/local/man/man3/iconv_open_into.3
/usr/local/man/man3/iconvctl.3
/usr/local/share/doc/libiconv/iconv.1.html
/usr/local/share/doc/libiconv/iconv.3.html
/usr/local/share/doc/libiconv/iconv_close.3.html
/usr/local/share/doc/libiconv/iconv_open.3.html
/usr/local/share/doc/libiconv/iconv_open_into.3.html
/usr/local/share/doc/libiconv/iconvctl.3.html

NOK Run encoding.iconv tests with tcc

$ ./v -stats test vlib/encoding/iconv/
---- Testing... ----
================== C compilation error (from tcc): ==============
cc: tcc: error: undefined symbol 'libiconv_open'
cc: tcc: error: undefined symbol 'libiconv'
cc: tcc: error: undefined symbol 'libiconv_close'
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

NOK Run encoding.iconv tests with gcc (egcc binary on OpenBSD)

./v -cc egcc -stats test vlib/encoding/iconv/
---- Testing... ----
builder error: Header file <iconv.h>, needed for module `encoding.iconv` was not found. Please install the corresponding development headers.

----
To reproduce just failure 1 run:    '/home/fox/dev/vlang.git/v' -cc egcc -stats '/home/fox/dev/vlang.git/vlib/encoding/iconv/iconv_test.v'
Summary for all V _test.v files: 1 failed, 1 total. Elapsed time: 2111 ms, on 1 job. Comptime: 0 ms. Runtime: 2106 ms.

NOK Run encoding.iconv tests with clang

$ ./v -cc clang -stats test vlib/encoding/iconv/
---- Testing... ----
builder error: Header file <iconv.h>, needed for module `encoding.iconv` was not found. Please install the corresponding development headers.

----
To reproduce just failure 1 run:    '/home/fox/dev/vlang.git/v' -cc clang -stats '/home/fox/dev/vlang.git/vlib/encoding/iconv/iconv_test.v'
Summary for all V _test.v files: 1 failed, 1 total. Elapsed time: 1519 ms, on 1 job. Comptime: 0 ms. Runtime: 1516 ms.

Expected Behavior

All tests OK for encoding.iconv with tcc, gcc and clang

Current Behavior

See above for test

WIth this issue, vdoctor does not work on OpenBSD current/amd64 with tcc, clang and gcc. With PR #23361 vdoctor uses now iconv encoding for its output.

$ ./v doctor
cannot compile `/home/fox/dev/vlang.git/cmd/tools/vdoctor.v`: 1
tcc: error: undefined symbol 'libiconv_open'
tcc: error: undefined symbol 'libiconv'
tcc: error: undefined symbol 'libiconv_close'
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

In vlib/encoding/iconv/iconv_nix.c.v file, add #flag for OpenBSD to find iconv includes and library.

I have this fix in my personal fork. I will post a PR with it.

Additional Information/Context

No response

V version

V 0.4.9 5be2fca

Environment details (OS name and version, etc.)

$ egcc -v
Using built-in specs.
COLLECT_GCC=egcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-openbsd7.6/11.2.0/lto-wrapper
Target: x86_64-unknown-openbsd7.6
Configured with: /usr/obj/ports/gcc-11.2.0/gcc-11.2.0/configure --with-as=/usr/local/bin/gas --with-stage1-ldflags=-L/usr/obj/ports/gcc-11.2.0/bootstrap/lib --verbose --program-transform-name='s,^,e,' --disable-nls --with-system-zlib --disable-libmudflap --disable-libgomp --disable-libssp --disable-tls --with-gnu-ld --with-gnu-as --enable-threads=posix --enable-wchar_t --with-gmp=/usr/local --enable-languages=c,c++,fortran,objc,ada,d --disable-libstdcxx-pch --enable-default-pie --enable-standard-branch-protection --without-isl --enable-default-ssp --enable-cpp --prefix=/usr/local --sysconfdir=/etc --mandir=/usr/local/man --infodir=/usr/local/info --localstatedir=/var --disable-silent-rules --disable-gtk-doc
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
  • clang 16.0.6
$ clang -v
OpenBSD clang version 16.0.6
Target: amd64-unknown-openbsd7.6
Thread model: posix
InstalledDir: /usr/bin

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@lcheylus lcheylus added the Bug This tag is applied to issues which reports bugs. label Jan 25, 2025
Copy link

Connected to Huly®: V_0.6-21999

lcheylus added a commit to lcheylus/v that referenced this issue Jan 25, 2025
lcheylus added a commit to lcheylus/v that referenced this issue Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant