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

more haiku support #10073

Merged
merged 7 commits into from Nov 25, 2021
Merged

more haiku support #10073

merged 7 commits into from Nov 25, 2021

Conversation

hoanga
Copy link

@hoanga hoanga commented Nov 1, 2021

Hello and happy halloween!

I was able to finally get some time to sit down and do some more continued work on improving Haiku support for Zig. The following changesets should allow

zig build in a (simple) zig project works

Running make install to install Zig after compiling probably doesn't work and is on the list of things todo. Debug still remains on the open list of items to tackle at some point but wanted to attempt with smaller changesets. Also included in the changes are some better error checking for some syscalls to Haiku and an attempted cleanup of some defines and constants in the Haiku support section that came across from an older copy and paste.

Getting Zig to compile on Haiku also meant using the current used version of LLVM (13) which is currently a (hopefully) pending port for Haiku. I am attaching some patches that I used to get LLVM to build on Haiku as well for reference but not including it in the PR changesets directly.

Sample Runs

~/src/git/zig/build> uname -a
Haiku shredder 1 hrev55602 Oct 29 2021 07:10:38 x86_64 x86_64 Haiku

~/src/git/zig/build> ./zig version
0.9.0-dev.1463+d97928bf5

## compiling with  simple program
~/src/git/zig/build> cd hellohaiku

~/src/git/zig/build/hellohaiku> cat src/main.zig 
const std = @import("std");
const thread = std.Thread;

pub fn main() anyerror!void {
    std.log.info("All your codebase are belong to us.", .{});
    std.log.info("Num CPUs: {d}.", .{thread.getCpuCount()});
}

~/src/git/zig/build/hellohaiku> ../zig build run
info: All your codebase are belong to us.
info: Num CPUs: 16.


### try using zig build on some other zig codebases

~/src/git/zig/build/ziglings> ../zig build 8
Compiling 008_quiz.zig...
Checking 008_quiz.zig...
PASSED: Program in Zig!


~/src/git/zig/build/ziglings> ../zig build 31
Compiling 031_switch2.zig...
Checking 031_switch2.zig...
PASSED: ZIG!!

@hoanga
Copy link
Author

hoanga commented Nov 1, 2021

patches applied to (zig-bootstrap) LLVM
llvm13-diff.patch.zip

@andrewrk
Copy link
Member

andrewrk commented Nov 1, 2021

CI is failing on zig fmt

@andrewrk
Copy link
Member

andrewrk commented Nov 1, 2021

CC @waddlesplash who gave me permission on IRC to ask for help reviewing :-)

@hoanga
Copy link
Author

hoanga commented Nov 2, 2021

oops, sorry about the fmt miss. i have gone through and double checked that all files that have been changed have had fmt applied to them and pushed updates, hopefully CI will find that more agreeable.

lib/std/c/haiku.zig Outdated Show resolved Hide resolved
lib/std/c/haiku.zig Outdated Show resolved Hide resolved
@@ -535,9 +569,6 @@ pub const O = struct {
pub const RDWR = 0x0002;
pub const ACCMODE = 0x0003;

pub const SHLOCK = 0x0010;
pub const EXLOCK = 0x0020;

pub const CREAT = 0x0200;
pub const EXCL = 0x0800;
pub const NOCTTY = 0x8000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants, also, do not seem to properly correspond to ours. They should probably all be fixed. (I think a lot of the constants not touched in these commits have similar problems, maybe a general review of the constants in this file is in order.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@andrewrk
Copy link
Member

andrewrk commented Nov 9, 2021

Let's please correct all the constants in this PR, and delete any constants that have not been audited. I don't want any incorrect haiku constants in the zig standard library. Let me know when that's done and I'll look into merging the PR.

@hoanga
Copy link
Author

hoanga commented Nov 11, 2021

thank you for the feedback. when i get some time (hopefully this weekend), i will try to look over the constants and get some updates in.

Al Hoang added 6 commits November 15, 2021 00:29
* add team_info, area_info
* update signature for get_next_image_info
* add error checks for haiku system calls
* update and cleanup of haiku constants
@hoanga
Copy link
Author

hoanga commented Nov 20, 2021

have went through and cleaned up as many of the constants so they should match the haiku definitions that i could find. i think it is ready for review (assuming the build is okay with it too)

@andrewrk
Copy link
Member

Thanks @hoanga!

@andrewrk andrewrk merged commit 36c8adf into ziglang:master Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants