Skip to content

stage1 compiler for dragonfly os + ravenports #2381

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

Closed
wants to merge 1 commit into from
Closed

stage1 compiler for dragonfly os + ravenports #2381

wants to merge 1 commit into from

Conversation

tse-gratis
Copy link

@tse-gratis tse-gratis commented Apr 29, 2019

Hiya,

This has the initial compiler working, so zig can compile executables on DragonFlyBSD. I'm intending it for ravenports, which is an os-independent port manager

The major issues (at least as far as I can see) are that

  1. src/link.cpp adds a few hardwired paths. Not sure of the best way around that
  2. The self-hosted compiler also prefers libc.so over libc.a, which creates the same warning as in link.cpp; but I'm not sure how to work around it there
  3. build-exe works, but running the tests with build --build-file ../build.zig test-behavior for zig-0.4.0 gives multiple
Created /home/tse/temp/zig/zig-cache/o/5sTF91oJatD4Un3mQd3J4BerAC631hjTpwibPGQiDbaJSe2ltByFEeeGZWFoim1T/test but skipping execution because it is non-native.

This is because x86_64-linux-gnu is getting passed into main.cpp at each test

Doing 3. for zig-master replaces zig-cache/native_libc.txt with the system paths (overwriting the raven paths that were used to build zig), and produces

Zig is unable to provide a libc for the chosen target 'x86_64-unknown-dragonfly-gnu'.
...
The following command exited with error code 1:
/home/tse/temp/zig/build/release/bin/zig test /home/tse/temp/zig/test/stage1/behavior.zig --test-name-prefix behavior-linux-x86_64-Debug-bare-multi  --cache-dir /home/tse/temp/zig/zig-cache --name test -target x86_64-dragonfly-gnu

I haven't debugged this issue, but at least simple build-exe works

Edit: this last zig-master issue was caused by copying an old native_libc.txt file from zig-0.4.0, and easily fixed

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Left some comments. Nice work!

@@ -0,0 +1,845 @@
const builtin = @import("builtin");

pub use @import("dragonfly/errno.zig");
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as for std/c/dragonfly.zig: can this be shared with freebsd.zig? This is the only difference between those files, isn't it?

Copy link
Author

Choose a reason for hiding this comment

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

I confess to having checked the other files for differences. But I left this one (other that errno). If there are differences with freebsd, I'm maybe not the person to fix them -- never having used 99% of what's in that file

Copy link
Member

Choose a reason for hiding this comment

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

Did you copy this file from FreeBSD? I'm worried that there are hard-to-catch bugs in here if there is anything different.

Copy link
Author

Choose a reason for hiding this comment

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

Originally yes it was copied. Now all defines are just wrappers around c/dragonfly.zig. Except for O_LARGEFILE. I initially special cased the dragonfly's absence of O_LARGEFILE in *.zig, but felt it was maybe better to just set O_LARGEFILE to the no-op of 0 for the moment

src/link.cpp Outdated
"-L/raven/share/raven/toolchain/gcc8/lib");
// prefer .a over .so
// fixes: lld: warning: found local symbol '__thread_locale' in global part of symbol table in file /raven/share/raven/sysroot/DragonFly/usr/lib/libc.so
lj->args.append("/raven/share/raven/sysroot/DragonFly/usr/lib/libc.a");
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker, just a question from an interested onlooker: how would someone who uses dports rather than ravenports use zig on dragonflybsd?

Copy link
Author

Choose a reason for hiding this comment

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

ravenports should work the same on linux/macos/solaris/freebsd/dragonfly and maybe netbsd. It looks like they will accept my port, if so, the command to install it will be

> /raven/sbin/pkg install zig-single-standard

And from there on it should be the same as dports -- though using /raven/lib etc rather than /usr/lib etc

@tse-gratis
Copy link
Author

tse-gratis commented Apr 30, 2019

These commits try to show the minimum change that gets the multithreaded tests working on dragonfly, but it does this by changing zigTriple() from cross_target.os to builtin.Os.dragonfly

With this commit, the tests on dragonfly all output something like

595/598 behavior.while.test "behavior-linux-x86_64-Debug-bare-multi continue outer while loop"...OK

Does the -linux- line mean it is assuming linux somewhere?

Note: the tests with --single-threaded fail with lld error: TLS attribute mismatch: errno. Which was defined with threadlocal

@tse-gratis
Copy link
Author

Just a small note to add: I sometimes see x86_64-unknown-dragonfly-gnu and x86_64-dragonfly-gnu. I assume target_parse_triple() always happens on the latter version, but still to be safe, I didn't add vendor to the native/target comparison. Since compilation takes >20mins on my laptop; testing that simple change could easily take me over an hour

andrewrk added a commit that referenced this pull request May 3, 2019
Previously if you had, for example:

extern "c" threadlocal var errno: c_int;

This would turn errno into a normal variable for --single-threaded
builds. However for variables with external linkage, there is an ABI
to uphold.

This is needed to make errno work for DragonFly BSD. See #2381.
Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

Hi @tse-gratis,

Nice work! I'm excited to merge this.

build-exe works, but running the tests with build --build-file ../build.zig test-behavior for zig-0.4.0 gives multiple "skipping execution because it is non-native"

This is actually working fine - DragonFly BSD is not in the test matrix so it is not getting tested by test-behavior:

zig/test/tests.zig

Lines 31 to 47 in f6937db

const test_targets = []TestTarget{
TestTarget{
.os = builtin.Os.linux,
.arch = builtin.Arch.x86_64,
.abi = builtin.Abi.gnu,
},
TestTarget{
.os = builtin.Os.macosx,
.arch = builtin.Arch.x86_64,
.abi = builtin.Abi.gnu,
},
TestTarget{
.os = builtin.Os.windows,
.arch = builtin.Arch.x86_64,
.abi = builtin.Abi.msvc,
},
};

You can manually run the behavior tests for the native target with ./zig test ../test/stage1/behavior.zig and the std lib tests with ./zig test ../std/std.zig --override-std-dir ../std.

Do we have any way to run CI tests for DragonFly BSD?

this last zig-master issue was caused by copying an old native_libc.txt file from zig-0.4.0, and easily fixed

Let's try to get it working with master. After fixing up code from my review comments, let me know what happens when you delete native_libc.txt and then try to link against libc.

Note: the tests with --single-threaded fail with lld error: TLS attribute mismatch: errno. Which was defined with threadlocal

I pushed a fix for this to master: bd9c629

src/link.cpp Outdated
@@ -872,7 +872,7 @@ static const char *getLDMOption(const ZigTarget *t) {
return "elf32_x86_64";
}
// Any target elf will use the freebsd osabi if suffixed with "_fbsd".
if (t->os == OsFreeBSD) {
if (t->os == OsFreeBSD || t->os == OsDragonFly) {
return "elf_x86_64_fbsd";
Copy link
Member

Choose a reason for hiding this comment

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

DragonFly BSD uses the "fbsd" suffix? Can you confirm this?

src/link.cpp Outdated
"-L/raven/share/raven/toolchain/gcc8/lib");
// prefer .a over .so
// fixes: lld: warning: found local symbol '__thread_locale' in global part of symbol table in file /raven/share/raven/sysroot/DragonFly/usr/lib/libc.so
lj->args.append("/raven/share/raven/sysroot/DragonFly/usr/lib/libc.a");
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it should be the crt_dir.

pub extern "c" fn clock_getres(clk_id: c_ulong, tp: *timespec) c_int;

/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
pub const Kevent = extern struct {
Copy link
Member

Choose a reason for hiding this comment

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

How did you come up with the extern function prototypes and the struct definitions in this file?

@@ -0,0 +1,845 @@
const builtin = @import("builtin");

pub use @import("dragonfly/errno.zig");
Copy link
Member

Choose a reason for hiding this comment

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

Did you copy this file from FreeBSD? I'm worried that there are hard-to-catch bugs in here if there is anything different.

@@ -0,0 +1,120 @@
pub const EPERM = 1; // Operation not permitted
Copy link
Member

Choose a reason for hiding this comment

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

What was the source of information for this file?

@tse-gratis
Copy link
Author

tse-gratis commented May 10, 2019

Testing functions can give runtime success/error -- even when they have untaken paths with comptime errors
I would much prefer testing/compiling to catch all comptime errors -- when branches (and even global functions) are not used

This issue first occured because I thought nextDragonFly() was compiling succesfully; since test runs were successful, but actually, it contains a compile time error of:
error: unable to perform binary not operation on type 'comptime_int'

I am still stuck on this. Wrapping the const next_index value with usize() in various places, such as ~usize(7) gives a long powi.zig stack trace with repeating Overflow...Underflow. Not sure what to do here. The relevant code to get const next_index is, I assume _DIRENT_RECLEN from sys/dirent.h (dragonfly has no dirent.d_reclen):

#define	_DIRENT_RECLEN(namelen) \
	((__offsetof(struct dirent, d_name) + (namelen) + 1 + 7) & ~7)
#define	_DIRENT_DIRSIZ(dp)	_DIRENT_RECLEN((dp)->d_namlen)
#define	_DIRENT_NEXT(dp) \
	((struct dirent *)((uint8_t *)(dp) + _DIRENT_DIRSIZ(dp)))

Other than this issue, it's mostly mutex/atomic/event tests failing. I got mutex.zig code compiling but core dumping, so I stripped it out

Thanks for all your help. Let me note these below issues too, so that I've covered everything

I've now added dragonfly to test.zig. Many tests run. But the command zig build --build-file ../build.zig test-behavior -Dskip-release still gives skipping execution because it is non-native. This is the issue that I was trying to fix (incorrectly) in src/target.cpp

Also running the command zig build --build-file ../build.zig test-behavior gives:

unreachable: /construction/zig/zig-0.4.0/src/ir.cpp:const_ptr_pointee_unchecked:193
the following command terminated unexpectedly:
/raven/bin/zig test /home/tse/packages/temp/zig/test/stage1/behavior.zig --test-name-prefix behavior-linux-x86_64-debug-bare-multi  --cache-dir /home/tse/packages/temp/zig/zig-cache --name test -target x86_64-linux-gnu

c/dragonfly.zig is now auto-generated with translate-c, and os/dragonfly.zig just wraps those values

When translating #define MAP_FAILED ((void *)-1) and compiling the generated code, zig gives:

/home/tse/Packages/temp/zig/build/release/lib/zig/std/c/dragonfly.zig:3602:204: error: C pointers cannot point to non-C-ABI-compatible type 'void'
pub const MAP_FAILED = if (@typeId(@typeOf(-1)) == @import("builtin").TypeId.Pointer) @ptrCast([*c]void, -1) else if (@typeId(@typeOf(-1)) == @import("builtin").TypeId.Int) @intToPtr([*c]void, -1) else ([*c]void)(-1);

So I just change that line to:

pub const MAP_FAILED =__UINTPTR_MAX__;
...
pub const __UINTPTR_MAX__ = c_ulong(18446744073709551615);

Other than that std/c/dragonfly.zig is essentially a direct translation

I just rebased to HEAD, and got this. Let me push it anyway.... :(

/home/tse/Packages/zig-master/std/c/dragonfly.zig:1:12: error: invalid token: 'threadlocal'
extern "c" threadlocal var errno: c_int;

@andrewrk
Copy link
Member

I just rebased to HEAD, and got this. Let me push it anyway.... :(

/home/tse/Packages/zig-master/std/c/dragonfly.zig:1:12: error: invalid token: 'threadlocal'
extern "c" threadlocal var errno: c_int;

@Hejsil can you take a look at this? I think this may be related to 6b10f03. extern threadlocal should be allowed, and it does seem to be allowed by the grammar.

@Hejsil
Copy link
Contributor

Hejsil commented May 11, 2019

@andrewrk Aah, i see. I forgot to eat a threadlocal keyword here:

zig/src/parser.cpp

Lines 593 to 595 in 6b10f03

if (first->id != TokenIdKeywordInline) {
AstNode *var_decl = ast_parse_var_decl(pc);
if (var_decl != nullptr) {

I'll fix this real quick.

@Hejsil
Copy link
Contributor

Hejsil commented May 11, 2019

Ok, maybe not real quick. I'm a little busy and don't have a computer on hand with a building version of Zig master.

@Hejsil
Copy link
Contributor

Hejsil commented May 11, 2019

@tse-gratis Should be fixed with c051904. Sorry for the inconvenience.

@tse-gratis
Copy link
Author

tse-gratis commented May 14, 2019

Thanks @Hejsil for making this possible

Quick overview:

  • c/dragonfly.zig review comments are now hopefully resolved. I've temporarily added the file c_to_zig.sh in the root dir to show how it was done. Apologies for using the less ubiquitous kak/kakoune for the script
  • I believe my zig cli issues are resolved (since is non-native is a correct error message, rather than a bug to be fixed):
    ./release/bin/zig test ../test/stage1/behavior.zig -- All tests passed
    ./release/bin/zig test ../std/std.zig --override-std-dir ../std -- 1098 passed; 19 skipped

Of those 19 skipped; they are the same as the previous commit: dirent.reclen in os.zig, mutex.zig, etc

pub const CTLTYPE_S16 = 13;
pub const CTLTYPE_NODE = 1;
pub const __PTRDIFF_FMTi__ = c"li";
pub const __SSE4_1__ = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is about your computer; not from dragonfly itself.

Copy link
Author

Choose a reason for hiding this comment

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

😳 Thanks @daurnimator 😉

Copy link
Author

Choose a reason for hiding this comment

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

Is this better?

pub const SF_XLINK = 16777216;
pub const S_IFSOCK = 49152;
pub const __GCC_ATOMIC_LLONG_LOCK_FREE = 2;
pub const __clang_version__ = c"8.0.0 (tags/RELEASE_800/final)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Things starting with __ are generally from the compiler.

pub const T_ALIGNFLT = 14;
pub const TIMER_ABSTIME = 1;
pub const SIG_BLOCK = 1;
pub const SIGCHLD = 20;
Copy link
Contributor

Choose a reason for hiding this comment

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

these should at least be sorted/grouped

@andrewrk
Copy link
Member

I'm sorry for the timing but that big branch I just merged moved a lot of standard library stuff around and you'll have to do some rebasing. It might make sense to look at a diff of your changes and then manually re-apply them to master. The good news is that it's highly likely the changes you have to make to support dragonfly will be much fewer.

@tse-gratis
Copy link
Author

tse-gratis commented May 30, 2019

I'm kind of running out of steam

This branch is still essentially waiting for review, but it has gained some new issues

  1. The std tests need pthread adding, with zig test ../std/std.zig --override-std-dir ../std --library pthread
  2. Some of the tests passed, and then later failed. I have added a few more if(dfly){return error.SkipZigTest}
  3. I wasn't completely clear on which path to place declarations in c/dragonfly.zig or os/dragonfly.zig or os/bits/dragonfly.zig. I've put most of it in c/dragonfly.zig, otherwise it has naming and type conflicts with linux.zig
  4. This branch adds about 1000 lines of fairly untestable code 😢 remove lazy analysis from zig #2529. Last night I noticed a few OpaqueTypes should be @OpaqueType

Other than those small things 😉 I realize the file c_to_zig.sh needs removing, and the commits need squashing down

@tse-gratis
Copy link
Author

The azure ci fails with
docgen.zig:791:29: error: container 'std.zig.tokenizer.Id' has no member called 'Keyword_usingnamespace'

So not really the code in this branch

And thanks, the rebasing changes were simpler

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

I think your rebase got messed up and reverted a bunch of stuff from master branch.

@@ -1857,7 +1857,7 @@ struct CodeGen {
BuildMode build_mode;
OutType out_type;
const ZigTarget *zig_target;
TargetSubsystem subsystem; // careful using this directly; see detect_subsystem
TargetSubsystem subsystem;
Copy link
Member

Choose a reason for hiding this comment

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

I think your rebase resolved some conflicts the wrong way

@@ -6,7 +6,7 @@ const builtin = @import("builtin");
const assert = std.debug.assert;
const ast = std.zig.ast;
const Token = std.zig.Token;
usingnamespace @import("clang.zig");
use @import("clang.zig");
Copy link
Member

Choose a reason for hiding this comment

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

usingnamespace is correct. You need to rebase against master again; this changed yesterday. See #2014

Copy link
Author

Choose a reason for hiding this comment

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

I swapped these back because they caused the ci to fail

Copy link
Member

Choose a reason for hiding this comment

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

the ci is green for master branch which has the usingnamespace syntax

src/analyze.cpp Outdated
@@ -2722,10 +2722,12 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi
if (ccc) {
if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) {
g->have_c_main = true;
g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemConsole : g->subsystem;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an accident from the rebase.

Copy link
Author

Choose a reason for hiding this comment

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

Okay thanks. I will need to try again

src/analyze.cpp Outdated
} else if (buf_eql_str(symbol_name, "WinMain") &&
g->zig_target->os == OsWindows)
{
g->have_winmain = true;
g->subsystem = g->subsystem == TargetSubsystemAuto ? TargetSubsystemWindows : g->subsystem;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an accident from the rebase.

Copy link
Author

Choose a reason for hiding this comment

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

Yikes. Hopefully the latest commit 80a0499 is better

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

One more change and then I think this is ready to merge.

return &errno;
}
pub const __sighandler_t = extern fn(c_int) void;
// auto import
Copy link
Member

Choose a reason for hiding this comment

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

The auto import brought in some undesirable stuff, such as NULL and probably more that isn't DragonFly OS specific. Due to zig's lazy analysis however this is mostly fine, as unused things are generally harmless.

Types and constants should be moved to std/os/bits/dragonfly.zig. The extern "c" functions should stay.

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2019

Oh, I also wanted to ask, why are all those tests disabled? What were the errors you were getting?

@tse-gratis
Copy link
Author

= Minor notes =
Cli needs pthread: ./release/bin/./zig test ../std/std.zig --override-std-dir ../std --library pthread

itimerspec conflicted with definition in os/linux.zig, so has been removed from os/bits/dragonfly.zig

Just to reflect the layout of freebsd: I kept fn WEXITSTATUS(s: u32) in bits/dragonfly.zig, and kept errno and _errno in c/dragonfly.zig

= Std test issues avoided with SkipZigTest =
mutex.zig: core dump
event/channel.zig: core dump
os/test.zig: the below trace

833/1122 os.test.test "makePath, put some files in it, deleteTree"...unexpected errno: 66
/home/tse/Packages/zig-master/std/debug.zig:96:27: 0x35f128 in debug.dumpCurrentStackTrace (test)
    writeCurrentStackTrace(stderr, debug_info, wantTtyColor(), start_addr) catch |err| {
                          ^
/home/tse/Packages/zig-master/std/os.zig:2442:40: 0x361c57 in os.unexpectedErrno (test)
        std.debug.dumpCurrentStackTrace(null);
                                       ^
/home/tse/Packages/zig-master/std/os.zig:885:45: 0x2a31f7 in os.unlinkC (test)
        else => |err| return unexpectedErrno(err),
                                            ^
/home/tse/Packages/zig-master/std/os.zig:860:23: 0x2a3143 in os.unlink (test)
        return unlinkC(&file_path_c);
                      ^
/home/tse/Packages/zig-master/std/fs.zig:298:23: 0x6648a9 in fs.deleteTree (test)
        if (deleteFile(full_path)) {
                      ^
/home/tse/Packages/zig-master/std/os/test.zig:21:22: 0x343a2a in os.test.test "makePath, put some files in it, deleteTree" (test)
    try fs.deleteTree(a, "os_test_tmp");
                     ^
/home/tse/Packages/zig-master/std/special/test_runner.zig:13:25: 0x85d23f in std.special.main (test)
        if (test_fn.func()) |_| {
                        ^
/home/tse/Packages/zig-master/std/special/bootstrap.zig:131:22: 0x85cf97 in std.special.main (test)
            root.main() catch |err| {
                     ^
???:?:?: 0x2a20cd in ??? (???)


???:?:?: 0x8008bdfff in ??? (???)


error: Unexpected
/home/tse/Packages/zig-master/std/math/powi.zig:60:21: 0x655c24 in math.powi.powi (test)
                    return error.Underflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:89:25: 0x656636 in math.powi.powi (test)
                        return error.Underflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:99:25: 0x657198 in math.powi.powi (test)
                        return error.Underflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:58:21: 0x654904 in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:58:21: 0x654f2a in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:58:21: 0x655559 in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:58:21: 0x655bb9 in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:87:25: 0x6565fb in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:97:25: 0x657152 in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:64:21: 0x65758d in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:64:21: 0x65791f in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:64:21: 0x657cbe in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:64:21: 0x658074 in math.powi.powi (test)
                    return error.Overflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:97:25: 0x6587d5 in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:97:25: 0x658e17 in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/os.zig:1005:19: 0x7799f3 in os.mkdirC (test)
        ENOENT => return error.FileNotFound,
                  ^
/home/tse/Packages/zig-master/std/os.zig:985:9: 0x779888 in os.mkdir (test)
        return mkdirC(&dir_path_c, mode);
        ^
/home/tse/Packages/zig-master/std/fs.zig:193:5: 0x779748 in fs.makeDir (test)
    return os.mkdir(dir_path, default_new_dir_mode);
    ^
/home/tse/Packages/zig-master/std/os.zig:1005:19: 0x7799f3 in os.mkdirC (test)
        ENOENT => return error.FileNotFound,
                  ^
/home/tse/Packages/zig-master/std/os.zig:985:9: 0x779888 in os.mkdir (test)
        return mkdirC(&dir_path_c, mode);
        ^
/home/tse/Packages/zig-master/std/fs.zig:193:5: 0x779748 in fs.makeDir (test)
    return os.mkdir(dir_path, default_new_dir_mode);
    ^
/home/tse/Packages/zig-master/std/os.zig:2444:5: 0x361c60 in os.unexpectedErrno (test)
    return error.Unexpected;
    ^
/home/tse/Packages/zig-master/std/os.zig:885:23: 0x2a3204 in os.unlinkC (test)
        else => |err| return unexpectedErrno(err),
                      ^
/home/tse/Packages/zig-master/std/os.zig:860:9: 0x2a315c in os.unlink (test)
        return unlinkC(&file_path_c);
        ^
/home/tse/Packages/zig-master/std/fs.zig:315:16: 0x66497f in fs.deleteTree (test)
            => return err,
               ^
/home/tse/Packages/zig-master/std/os/test.zig:21:5: 0x343a51 in os.test.test "makePath, put some files in it, deleteTree" (test)
    try fs.deleteTree(a, "os_test_tmp");
    ^
/home/tse/Packages/zig-master/std/special/test_runner.zig:21:21: 0x85d179 in std.special.main (test)
            else => return err,
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:87:25: 0x6586e1 in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:87:25: 0x658cde in math.powi.powi (test)
                        return error.Overflow;
                        ^
/home/tse/Packages/zig-master/std/math/powi.zig:60:21: 0x65495d in math.powi.powi (test)
                    return error.Underflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:60:21: 0x654f85 in math.powi.powi (test)
                    return error.Underflow;
                    ^
/home/tse/Packages/zig-master/std/math/powi.zig:60:21: 0x6555b4 in math.powi.powi (test)
                    return error.Underflow;

@daurnimator
Copy link
Contributor

itimerspec conflicted with definition in os/linux.zig, so has been removed from os/bits/dragonfly.zig

Why was that a problem?

@andrewrk
Copy link
Member

andrewrk commented Jul 2, 2019

I had a look at this today. There is still more to do before it's merge-ready:

  • all the skipped tests need comments explaining why the test is skipped, and what needs to happen so that the test can be enabled.
  • merge master & fix conflicts
  • I'm a little uncomfortable with how much stuff from translate-c is committed directly without being audited/cleaned up. For example, this has no business being in the Zig standard library: pub const DFLTPHYS = if (@typeId(@typeOf(1024)) == @import("builtin").TypeId.Pointer) @ptrCast([*c]64, 1024) else if (@typeId(@typeOf(1024)) == @import("builtin").TypeId.Int) @intToPtr([*c]64, 1024) else ([*c]64)(1024); . I think it would be better to actually lean into zig's lazy analysis a little bit here, and do a more minimal PR to get hello world working, and then iterate on some of the tests, getting them passing one at a time, and so on.

@andrewrk
Copy link
Member

andrewrk commented Jul 8, 2019

I'm closing this since there has been no progress for 1 month.

@tse-gratis or anyone else who wants to continue working on this, please feel free to open a new pull request.

In the future I would suggest smaller, incremental patches, taking advantage of Zig's lazy analysis. Get the stage0 compiler building. Pull Request. Get Hello World working. Pull Request. Then move on to more advanced test cases. Doing it all at once can be overwhelming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants