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

Create a build of Bun that doesn’t need AVX2 instructions #67

Closed
Jarred-Sumner opened this issue Nov 19, 2021 · 29 comments
Closed

Create a build of Bun that doesn’t need AVX2 instructions #67

Jarred-Sumner opened this issue Nov 19, 2021 · 29 comments

Comments

@Jarred-Sumner
Copy link
Collaborator

This can be feature detected in the install script

It’s really stupid for people to be unable to use Bun on older computers

@qnxdev
Copy link

qnxdev commented Jul 7, 2022

What next?

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

For the time being, I've made a script to simplify and automate SDE's installation based on @renhiyama 's solution, lmk if there's anything to fix.

$ curl https://gist.githubusercontent.com/fuka-g/afb29296db34d2451cdddcc14dbeef3c/raw/0c9e5d43910cf53b9bd82b358559bb8b75ebbfdc/bun-sde-fix-install_script.sh | bash

EDIT: Updated script, this one is up to date.

@guest271314

This comment was marked as off-topic.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

@fuka-g I followed those instructions. Now how do I run bun? Nothing chnaged on Linux 5.4.0-42-lowlatency x64.

Did you restart your shell ?

@guest271314

This comment was marked as off-topic.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

No. I am running a live system from RAM.

I can download the Node.js executable node and QuickJS executable qjs and run a JavaScript runtime out of the box.

This makes no sense to build an executable that throws by default.

Reload the terminal, not the OS

@guest271314

This comment was marked as off-topic.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

$ ./test.js
Illegal instruction (core dumped)

$ bun run test.js ?

@guest271314

This comment was marked as off-topic.

@renhiyama
Copy link

@guest271314 restart your terminal and then try again, should be working

@renhiyama
Copy link

also you should be running bun and not ./bun

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@renhiyama
Copy link

and thats not gonna work for you...

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

This is test.js

#!/usr/bin/env -S ./bun 
console.log('Hello, World!');

You're still using the original bun executable.

The script does not patch bun, but uses SDE as a middleman to handle the avx2 set.

You have to run bun run test.js, which will be an alias for sde -- bun, and not ./test.js, which will use the original bun.

@Nugine
Copy link

Nugine commented Jul 9, 2022

Hi. Rust can check CPU features and whether the OS supports them.
Is it fine to use rust for feature detection and link a rust static lib into bun?
See https://doc.rust-lang.org/stable/std/arch/macro.is_x86_feature_detected.html

@guest271314

This comment was marked as off-topic.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

Hi. Rust can check CPU features and whether the OS supports them. Is it fine to use rust for feature detection and link a rust static lib into bun? See https://doc.rust-lang.org/stable/std/arch/macro.is_x86_feature_detected.html

AFAIK the issue is that we don't support devices without AVX2 at all yet, not that we can't tell if they support that instruction set or not.

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@Nugine
Copy link

Nugine commented Jul 9, 2022

Hi. Rust can check CPU features and whether the OS supports them. Is it fine to use rust for feature detection and link a rust static lib into bun? See https://doc.rust-lang.org/stable/std/arch/macro.is_x86_feature_detected.html

AFAIK the issue is that we don't support devices without AVX2 at all yet, not that we can't tell if they support that instruction set or not.

We usually check whether the environment has AVX2 and run fallback functions instead of SIMD functions. I think it's the right way to support old devices.

if (is_avx2_enabled()) {
    return call_avx2_fn();
}
return call_fallback_fn();

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

More unecessary complications not documented in README.md and that does not work:

Because it's a pretty new bug, and should not be documented because it should not be a problem in the first place.

Can you send the output of ls -a ~/.sde ? It should output

.   ia32     Licenses  pinkit      sde    sde64.sig  xed    xed64.sig
..  intel64  misc      README.txt  sde64  sde.sig    xed64  xed.sig

If not, the installation is faulty somehow, which would be either an issue with curl or tar.

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

In any event, you need to conspicuously document the limitations and resrictions and dependencies necessary to use bun. Else you are hiding your flaws, in plain sight, no less.

I imagine you read the top of the README carefully and noticed this line: bun is experimental software. That means that, bun still being in beta, there can be (and you are to expect) issues that are not discovered yet, not documented and/or not patched yet. You can't expect bun to be as stable as node. Doc updates needs someone to fork the repo, commit changes, create a PR and wait for it to be reviewed and merged, so this takes time. Bun is relatively new and the v0.1.0 has been released 4 days ago.

Is the Intel download expected to be applicable for an AMD CPU?

No. At least not officially.

That might be the problem. Look up if there is an emulator for AMD CPUs. If so, you can apply the same workaround. I won't be of any help since all my computers are running on Intel CPUs.

@zekefeu
Copy link

zekefeu commented Jul 9, 2022

This issue is cause by an instruction set that is not present on older CPUs. I believe that the contributors are all running on modern CPUs, so they didn't run into this issue before the release of v.0.1.0.

@oven-sh oven-sh locked as off-topic and limited conversation to collaborators Jul 9, 2022
@evanwashere
Copy link
Collaborator

This issue was created for tracking progress
You can use troubleshooting instructions to emulate avx2 using Intel SDE, if you encounter any issues please use discussions or join our discord for support

@xhyrom
Copy link
Collaborator

xhyrom commented Aug 4, 2022

Done, see latest release *-baseline builds.

@xhyrom xhyrom closed this as completed Aug 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants