-
-
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
initial arm64 support #1429
initial arm64 support #1429
Conversation
shawnl
commented
Aug 27, 2018
•
edited
Loading
edited
- _start
- syscalls
- clone
- vdso
I'm happy to add arm support, but the biggest showstopper is #835 - if we can't get automated tests running on every pushed commit, we can't add support. The biggest step anyone can do toward getting zig to support another target is solving the CI problem. |
ok, the hello world builds in --release-fast mode, just not debug mode, as there are problems with the atomics (which compile out) and maybe other bugs. That is why I closed it, I wanted more to work |
This PR depends on having CI for ARM. |
c1a1012
to
8b6bd05
Compare
CI for arm https://buildbot.git.icu/buildbot/ builds on pushes to master, and if you set up github webhooks to https://buildbot.git.icu/buildbot/change_hook/github (push) then it will build on pull requests. I don't know how to get it integrated in the github GUI. |
2599ed7
to
789ee9e
Compare
llvm is generating garbage assembly https://bugs.llvm.org/show_bug.cgi?id=38734 which this bug is blocked on. also, the CI is timing out on windows and max osx. |
This might be zig doing the C ABI incorrectly. LLVM sadly does not provide the C ABI. I would check the equivalent LLVM IR generated by clang and compare. |
Oh, wait, that does seem like an llvm bug because your code is not doing the c ABI. Nevermind previous comment. |
30e22c9
to
e7ca743
Compare
these don't exist on new platforms (such as arm64) also switch from the deprecated dirent to dirent64
arm64 complains about the old value (I added a test)
From IEEE-754 standard: Conversion of a quiet NaN in a supported format to an external character sequence shall produce a language-defined one of “nan” or a sequence that is equivalent except for case (e.g., “NaN”), with an optional preceding sign. (This standard does not interpret the sign of a NaN.)
Auxillery vectors are not guaranteed to be in any order, this just happens to work on x86_64.
} | ||
return 0; |
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.
should this return null, and make the return ?usize
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.
The libc version doesn't distinguish, so the zig-native version matches the API.
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 looks really good. I have a few things to address, and then it's ready for merge.
@@ -1034,11 +1034,6 @@ test "fmt.format" { | |||
const result = try bufPrint(buf1[0..], "f64: {}\n", math.nan_f64); | |||
assert(mem.eql(u8, result, "f64: nan\n")); | |||
} | |||
{ |
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.
can you disable this test only for ARM?
if (builtin.arch ...
std/os/linux/index.zig
Outdated
@@ -624,6 +625,54 @@ pub const S_IWOTH = 0o002; | |||
pub const S_IXOTH = 0o001; | |||
pub const S_IRWXO = 0o007; | |||
|
|||
pub const O_CREAT = 0o100; |
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.
Although these constants are the same on x86_64 and aarch64, they are per-architecture values:
andy@xps ~/d/musl> grep -RI O_CREAT
arch/mips64/bits/fcntl.h:#define O_CREAT 0400
arch/generic/bits/fcntl.h:#define O_CREAT 0100
arch/x32/bits/fcntl.h:#define O_CREAT 0100
arch/powerpc64/bits/fcntl.h:#define O_CREAT 0100
arch/arm/bits/fcntl.h:#define O_CREAT 0100
arch/s390x/bits/fcntl.h:#define O_CREAT 0100
arch/mips/bits/fcntl.h:#define O_CREAT 0400
arch/x86_64/bits/fcntl.h:#define O_CREAT 0100
arch/aarch64/bits/fcntl.h:#define O_CREAT 0100
arch/m68k/bits/fcntl.h:#define O_CREAT 0100
arch/mipsn32/bits/fcntl.h:#define O_CREAT 0400
arch/powerpc/bits/fcntl.h:#define O_CREAT 0100
I think they should stay in the per-architecture files to prevent bugs when more architecture support is added in the future.
std/os/linux/index.zig
Outdated
@@ -1189,17 +1272,22 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags: | |||
} | |||
|
|||
pub fn fstat(fd: i32, stat_buf: *Stat) usize { | |||
return syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf)); | |||
return fstatat(fd, c"", stat_buf, AT_EMPTY_PATH); |
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.
I don't think this is really important, but, is there a benefit to not calling fstat? The previous version of this function does slightly less work, since it has to set up 2 fewer parameters, and it supports older kernels. (Same question for e.g. epoll_pwait
.)
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.
Drive-by comment: arm64 doesn't have an epoll_wait() syscall, only epoll_pwait(). libc emulates epoll_wait() as epoll_pwait() with a null sigmask, just like this PR does.
(Arm64 does have fstat() though, so no reason I can see to use fstatat().)
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.
arm64 also has execve and execveat
std/os/index.zig
Outdated
@@ -633,16 +633,21 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError { | |||
}; | |||
} | |||
|
|||
pub var linux_aux_raw = []usize{0} ** 38; | |||
pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = undefined; |
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 looks like you want this to be initialized to null
, not undefined
.
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.
but it is always set at program initialization, initializing it to null requires more code in every executable. I make it a maybe because one might want to unmap the entire elf auxiliary vector to save space.
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 is not set at program initialization when zig code is used as a library, with main
in a C object, for example. It's also not set at program initialization when the user puts export fn main(argc: c_int, argv: [*][*]u8) c_int {...}
and links with libc. Why would initializing it to null require more code? It's static data, so if it's null it would go in the .bss section.
I believe the current buildbot failures are due to building against llvm 6 instead of llvm 7. |
src/os.cpp
Outdated
@@ -839,9 +839,9 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args, | |||
if ((err = pipe(stderr_pipe))) | |||
zig_panic("pipe failed"); | |||
|
|||
pid_t pid = fork(); | |||
pid_t pid = vfork(); |
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 should be posix_spawn
rather than vfork. See #1620
1d8040b
to
f19d421
Compare
Looks good to me. Are you ready for me to merge? |
By the way, it looks like the buildbot environment has the wrong llvm/clang version. |
That is the fault of this line: cmake/Findllvm.cmake: NAMES llvm-config llvm-config-7 llvm-config-7.0 llvm-config on debian still points to llvm-config-6 should i prepare a patch? |
yes |
I just went ahead and fixed it in master. And I'll merge this PR too. Excellent work. |
Looks like the build bot environment is not fixed by the Findllvm.cmake change |