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

chore(compile): prefer denort binary in target/ directory when available #27052

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

irbull
Copy link
Contributor

@irbull irbull commented Nov 25, 2024

Enhances the deno compile workflow for denort development by automatically checking for a denort binary in the same directory as the deno binary, provided both are located within a target/ directory. If found, this denort binary will be used.

Key points:

  • The DENORT_BIN environment variable remains supported for explicitly specifying a custom denort binary path.
  • Includes additional logic to verify if the deno binary is a symlink pointing to an executable in the target/ directory.

Enhances the deno compile workflow for denort development by
automatically checking for a denort binary in the same directory as the
deno binary, provided both are located within a target/ directory. If
found, this denort binary will be used.

Key points:

- The DENORT_BIN environment variable remains supported for explicitly
  specifying a custom denort binary path.
- Includes additional logic to  verify if the deno binary is a symlink
  pointing to an executable in the target/ directory.
Comment on lines 923 to 935
env::current_exe().ok().and_then(|exec_path| {
if is_in_target(&exec_path) {
get_denort(exec_path)
} else if exec_path.is_symlink() {
fs::read_link(&exec_path).ok().and_then(|target_path| {
if is_in_target(&target_path) {
get_denort(target_path)
} else {
None
}
})
} else {
None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think we should only do this for "debug" builds, or check that the path includes target/debug? Or is there value in providing this for release builds too?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I sometimes do it for performance related stuff. I kind of wonder if we should do this even when not in the target directory, but this will be a nice change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's keep it for target/ for now and see how it works. We could broaden this in the future to always check for denort next to the deno executable.

Can you test this on Windows? I guess the rt file is called denort there too (without a file extension).

@dsherret dsherret changed the title feat: prefer denort binary in target/ directory when available chore(compile): prefer denort binary in target/ directory when available Nov 25, 2024
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks! Just one question left in a comment.

Comment on lines 927 to 933
fs::read_link(&exec_path).ok().and_then(|target_path| {
if is_in_target(&target_path) {
get_denort(target_path)
} else {
None
}
})
Copy link
Member

Choose a reason for hiding this comment

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

What's the value of the symlink check? Maybe let's remove this symlink branch to keep it simpler (less things that can go wrong)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The symlink check determines if the deno executable is in fact just a sym link and if so, it checks that the symbolic link points to an executable in a target/ directory. This is useful if you link your deno executable from your cargo/bin directory to your target directory.

But you're right, a lot more can go wrong including file handling on different platforms. I've removed this check.

Comment on lines 923 to 935
env::current_exe().ok().and_then(|exec_path| {
if is_in_target(&exec_path) {
get_denort(exec_path)
} else if exec_path.is_symlink() {
fs::read_link(&exec_path).ok().and_then(|target_path| {
if is_in_target(&target_path) {
get_denort(target_path)
} else {
None
}
})
} else {
None
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I sometimes do it for performance related stuff. I kind of wonder if we should do this even when not in the target directory, but this will be a nice change.

cli/standalone/binary.rs Outdated Show resolved Hide resolved
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@dsherret dsherret merged commit 3a55b67 into denoland:main Nov 26, 2024
17 checks passed
bartlomieju pushed a commit that referenced this pull request Nov 28, 2024
…ble (#27052)

Enhances the deno compile workflow for denort development by
automatically checking for a denort binary in the same directory as the
deno binary, provided both are located within a target/ directory. If
found, this denort binary will be used.
    
Key points:

- The DENORT_BIN environment variable remains supported for explicitly
specifying a custom denort binary path.
- Includes additional logic to verify if the deno binary is a symlink
pointing to an executable in the target/ directory.

---------

Signed-off-by: Ian Bull <[email protected]>
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.

2 participants