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

libbacktrace not supported on OpenBSD #22261

Open
lcheylus opened this issue Sep 19, 2024 · 3 comments
Open

libbacktrace not supported on OpenBSD #22261

lcheylus opened this issue Sep 19, 2024 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs. OS: OpenBSD Bugs/feature requests, that are specific to OpenBSD OS.

Comments

@lcheylus
Copy link
Contributor

lcheylus commented Sep 19, 2024

Describe the bug

libbacktrace is not supported on OpenBSD => error when building V code with -d use_libbacktrace flag.

Reproduction Steps

  • Build Vlang on OpenBSD/amd64

  • Clone sources from Git for v-analyzer => https://github.com/vlang/v-analyzer

  • Try to build v-analyzer in normal mode => -d use_libbacktrace used in build.vsh script

Expected Behavior

No error when building V code with -d use_libbacktrace on OpenBSD.

Current Behavior

Error when building v-analyzer on OpenBSD:

$ ~/dev/vlang.git/v build.vsh
Building v-analyzer at commit: 0086b35, build time: 2024-09-19 15:58:49 ...
✓ Prepared output directory
Building v-analyzer in debug mode, using: "/home/fox/dev/vlang.git/v" "/home/fox/dev/v-analyzer.git" -o "./bin/v-analyzer" -no-parallel   -g -d use_libbacktrace
To build in release mode, run v build.vsh release
Release mode is recommended for production use. At runtime, it is about 30-40% faster than debug mode.
[ERROR] Failed to build v-analyzer
failed thirdparty object build cmd:
'/home/fox/dev/vlang.git/thirdparty/tcc/tcc.exe' -std=c99 -D_DEFAULT_SOURCE   -g  -fPIC -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/usr/local/include" -I "/home/fox/dev/vlang.git/thirdparty/libbacktrace" -o '/home/fox/.vmodules/cache/c2/c260b323385da074280a69d697f32fd6.module.builtin.o' -c '/home/fox/dev/vlang.git/thirdparty/libbacktrace/backtrace.c'
builder error: In file included from /home/fox/dev/vlang.git/thirdparty/libbacktrace/backtrace.c:103:
/home/fox/dev/vlang.git/thirdparty/libbacktrace/base.c:3778: error: 'KERN_PROC_PATHNAME' undeclared

Possible Solution

In thirdparty/libbacktrace/base.c, symbol KERN_PROC_PATHNAME used by syscall is unknown on OpenBSD.

It's a known issue on OpenBSD => devs don't want implement KERN_PROC_PATHNAME for syscall to locate the current executable path. :( See this response from Theo on OpenBSD misc mailing-list https://marc.info/?l=openbsd-misc&m=144987773230417&w=2

An alternate solution is to use whereami library on OpenBSD to fix this issue in libbacktrace => https://github.com/gpakosz/whereami

I will try to reproduce this problem on OpenBSD with the current version of libbacktrace and to create a similar issue upstream.

After fix and merge upstream, I propose to update libbacktrace in Vlang sources (using amalgamation). Do you agree?

Additional Information/Context

No response

V version

./v version V 0.4.7 9a0f4d8

Environment details (OS name and version, etc.)

V full version: V 0.4.7 63957f2.9a0f4d8
OS: openbsd, 7.6, GENERIC.MP#312
Processor: 2 cpus, 64bit, little endian

getwd: /home/fox/dev/vlang.git
vexe: /home/fox/dev/vlang.git/v
vexe mtime: 2024-09-19 13:51:18

vroot: OK, value: /home/fox/dev/vlang.git
VMODULES: OK, value: /home/fox/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.46.1
Git vroot status: weekly.2024.37-30-g9a0f4d84
.git/config present: true

CC version: OpenBSD clang version 16.0.6
thirdparty/tcc status: thirdparty-openbsd-amd64 8205cc59

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 Sep 19, 2024
@lcheylus
Copy link
Contributor Author

Simple test to generate error when using libbacktrace on OpenBSD/amd64:

./v -d use_libbacktrace run ~/tmp/hello_world.v
failed thirdparty object build cmd:
'/home/fox/dev/vlang.git/thirdparty/tcc/tcc.exe' -std=c99 -D_DEFAULT_SOURCE    -fPIC -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/usr/local/include" -I "/home/fox/dev/vlang.git/thirdparty/libbacktrace" -o '/home/fox/.vmodules/cache/61/61fc8f5bdfdffed4bcf6b1b1604f5a61.module.builtin.o' -c '/home/fox/dev/vlang.git/thirdparty/libbacktrace/backtrace.c'
builder error: In file included from /home/fox/dev/vlang.git/thirdparty/libbacktrace/backtrace.c:103:
/home/fox/dev/vlang.git/thirdparty/libbacktrace/base.c:3778: error: 'KERN_PROC_PATHNAME' undeclared

=> error with KERN_PROC_PATHNAME' not defined on OpenBSD

@spytheman
Copy link
Member

After fix and merge upstream, I propose to update libbacktrace in Vlang sources (using amalgamation). Do you agree?

Yes, that will be nice.

@spytheman spytheman added the OS: OpenBSD Bugs/feature requests, that are specific to OpenBSD OS. label Sep 20, 2024
@lcheylus
Copy link
Contributor Author

After fix and merge upstream, I propose to update libbacktrace in Vlang sources (using amalgamation). Do you agree?

Yes, that will be nice.

OK, I have created a specific issue #22268 to track this update of thirparty/libbacktrace sources. This issue is focused on OpenBSD support of libbacktrace.

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. OS: OpenBSD Bugs/feature requests, that are specific to OpenBSD OS.
Projects
None yet
Development

No branches or pull requests

2 participants