Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ziglang/zig
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 48985a7e684f
Choose a base ref
...
head repository: ziglang/zig
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1aa93808b18e
Choose a head ref
  • 6 commits
  • 1 file changed
  • 2 contributors

Commits on Jun 18, 2018

  1. Fix 1117: Use realpath in stage1 Darwin os_self_exe_path

    Issue: #1117
    
    The macOS stage1 Zig compiler should look in Zig's real absolute path
    for the Zig stdlib, but os_self_exe_path looks in its path as returned
    by _NSGetExecutablePath, which may be a symlink.  This means that a
    symlinked Zig cannot find the Zig stdlib.
    
    This patch fixes the issue by resolving the _NSGetExecutablePath result
    to the real path using realpath() before copying the result to the
    output path.
    jbsolomon committed Jun 18, 2018

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jbsolomon Bodie Solomon
    Copy the full SHA
    e6b6915 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jbsolomon Bodie Solomon
    Copy the full SHA
    0456822 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jbsolomon Bodie Solomon
    Copy the full SHA
    c7057bd View commit details
  4. Merge branch 'fix-1117-macos-realpath' of https://github.com/binary13…

    …2/zig into binary132-fix-1117-macos-realpath
    andrewrk committed Jun 18, 2018
    Copy the full SHA
    c09c390 View commit details
  5. Copy the full SHA
    4ce36a6 View commit details
  6. Copy the full SHA
    1aa9380 View commit details
Showing with 19 additions and 2 deletions.
  1. +19 −2 src/os.cpp
21 changes: 19 additions & 2 deletions src/os.cpp
Original file line number Diff line number Diff line change
@@ -989,12 +989,29 @@ int os_self_exe_path(Buf *out_path) {
}

#elif defined(ZIG_OS_DARWIN)
// How long is the executable's path?
uint32_t u32_len = 0;
int ret1 = _NSGetExecutablePath(nullptr, &u32_len);
assert(ret1 != 0);
buf_resize(out_path, u32_len);
int ret2 = _NSGetExecutablePath(buf_ptr(out_path), &u32_len);

// Make a buffer having room for the temp path.
Buf *tmp = buf_alloc_fixed(u32_len);

// Fill the executable path.
int ret2 = _NSGetExecutablePath(buf_ptr(tmp), &u32_len);
assert(ret2 == 0);

// Resolve the real path from that.
buf_resize(out_path, PATH_MAX);
char *real_path = realpath(buf_ptr(tmp), buf_ptr(out_path));
if (!real_path) {
buf_init_from_buf(out_path, tmp);
return 0;
}

// Resize out_path for the correct length.
buf_resize(out_path, strlen(buf_ptr(out_path)));

return 0;
#elif defined(ZIG_OS_LINUX)
buf_resize(out_path, 256);