magic-akari/swc_mut_cjs_exports

Is SSE2 required? Can it not be?

Closed this issue · 6 comments

Running jest with jest_workaround on an Apple Macbook Pro with an M1 Pro, I get:

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/...path redacted.../dev/jest-setup-framework.js")'

Caused by:
    0: Failed to create plugin instance
    1: missing requires CPU features: "EnumSet(SSE2)"', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.245.20/src/plugin.rs:228:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 FAIL  test/models/article.db.test.js
  ● Test suite failed to run

    failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("/Users/...path redacted.../dev/jest-setup-framework.js")'

    Caused by:
        0: Failed to create plugin instance
        1: missing requires CPU features: "EnumSet(SSE2)"

      at Compiler.transformSync (node_modules/@swc/core/index.js:241:29)
      at transformSync (node_modules/@swc/core/index.js:348:21)
      at Object.process (node_modules/@swc/jest/index.js:73:45)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:542:31)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:671:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:723:19)

I don't know much about Rust, but it looks like maybe something is requiring SSE2? Could the build config be altered to not require it, or use ARM64 equivalents when building on that architecture?

@kdy1 @kwonoj Do you have any idea about this issue?

kdy1 commented

Are you using m1?
SSE2 is required for x86 but not m1

kdy1 commented

Can you check your node_modules?
I think you are using binary for x86.

Did you install node js for x86 with Rosseta?

I've installed node for arm64, and as far as I can tell, it is being used for running jest.

$ which jest
./node_modules/.bin/jest

Contents of ./node_modules/.bin/jest:

#!/usr/bin/env node
/**
 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const importLocal = require('import-local');

if (!importLocal(__filename)) {
  require('jest-cli/bin/jest');
}

node arch:

$ /usr/bin/env node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> process.arch
'arm64'

This was resolved by removing the project's .swc directory, which had been checked into source control. If that directory is used for caching (not sure it is, just guessing), it might be advisable to include arch as part of the cache key. Or specify in docs not to check it in.