-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
OpenBSD port #5324
OpenBSD port #5324
Conversation
7225bf1
to
2f5b8ca
Compare
First get zig building against static llvm/clang/lld libraries. There are many ways to build llvm and we don't ensure our cmake can deal with them all. It can deal with a minimalist static build of llvm and my brain cannot recall if llvm can be built with both static/dynamic libraries, please don't do so even if llvm allows it. If it helps, around time of #4803 I have an llvm-tarball that was linking zig0. It's here . |
var prg_name = argv[0]; | ||
if (prg_name[0] == '/' or prg_name[0] == '.') { | ||
return os.realpathZ(prg_name, out_buffer); | ||
} | ||
prg_name = mem.spanZ(prg_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code assumes pathname beginning with .
is a path component of either .
or ..
but it could also be a dot-named file. Let's use std.mem.indexOfScalar(..., '/')
to detect idx == 0
or "."
or ".."
here.
if (*prg_name == '/' || *prg_name == '.') { | ||
buf_init_from_str(tmp, prg_name); | ||
return os_path_real(tmp, out_path); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. handle 3 cases explicitly as lib/std/fs.zig
equivalent
// Look for the program in the set of directories | ||
char *path, *paths = buf_ptr(tmp); | ||
while ((path = strsep(&paths, ":")) != nullptr) { | ||
snprintf(out, PATH_MAX, "%s/%s", path, prg_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- use
buf_sprintf
instead ofsnprintf
- use
memSplit
instead ofstrsep
@@ -1655,6 +1664,48 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 { | |||
// TODO could this slice from 0 to out_len instead? | |||
return mem.spanZ(@ptrCast([*:0]u8, out_buffer)); | |||
}, | |||
.openbsd => { | |||
// OpenBSD has no support for this. Out of the various tried methods, | |||
// the only working workaround comes from stackoverflow.com/a/31495527 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to not implement this at all then it is to have a workaround.
I suggest to take advantage of zig's lazy top level declaration analysis, and the fact that we don't have any OpenBSD CI tests to regress, and break this into a series of smaller changes, landing your progress into master branch. Progress towards another operating system support does not have to be in one giant PR that does everything, you can make progress one piece at a time. This will prevent a situation like this right now, where an entire body of work is abandoned, even though it has plenty of useful changes which could have easily landed in master. Thanks for your work, I hope we can get some of it landed. |
First time contribution, a follow-up to #1921. This requires OpenBSD
-current
or 6.7 (related to #4803), which is slated for release on the 19th. Furthermore, LLVM 10 also needs to be compiled.Sadly, as it stands, I couldn't get Zig to compile properly (excerpt follows):
Running a debugger yields:
I've tried a few things to no avail. Looking for other people's input (@mikdusan? @jreut?), hence opening this draft PR.