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

cargo build --release: cannot find macro asm in this scope #2

Closed
jasonm opened this issue Jan 18, 2022 · 4 comments · Fixed by #3
Closed

cargo build --release: cannot find macro asm in this scope #2

jasonm opened this issue Jan 18, 2022 · 4 comments · Fixed by #3
Labels
bug Something isn't working

Comments

@jasonm
Copy link
Contributor

jasonm commented Jan 18, 2022

Expected behavior

Hello! When I clone this repo and run make create-synthetic-network and then make run-chrome, I would expect the latter command to build the Docker image and exit successfully per the README.

Describe the bug (unexpected behavior)

Instead, when I clone this repo and run make run-chrome the docker build (...) errors while running cargo build --release:

Click to expand a shell session of the build and error log
~/dev $ git clone https://github.com/daily-co/synthetic-network.git
Cloning into 'synthetic-network'...
remote: Enumerating objects: 1446, done.
remote: Counting objects: 100% (1446/1446), done.
remote: Compressing objects: 100% (1187/1187), done.
remote: Total 1446 (delta 215), reused 1445 (delta 215), pack-reused 0
Receiving objects: 100% (1446/1446), 4.77 MiB | 6.21 MiB/s, done.
Resolving deltas: 100% (215/215), done.

1s ~/dev $ cd synthetic-network/

0s (main) ~/dev/synthetic-network $ ls
CODE_OF_CONDUCT.md Dockerfile         Makefile           aarch64.nix        doc                run-in-vnc.sh      setup.sh
CONTRIBUTING.md    LICENSE            README.md          default.nix        frontend           rush               synth-chrome

0s (main) ~/dev/synthetic-network $ make create-synthetic-network
export SYNTHETIC_NETWORK=10.77.0.0/16
docker network create synthetic-network --subnet=10.77.0.0/16
a349f6a728c19feddf76a4af9f021d4b967d30aa5045d0ffcd5df6ebffe52cc3

7s (main) ~/dev/synthetic-network $ make run-chrome
docker build -t syntheticnet:vnc --build-arg VNC=true .
[+] Building 100.4s (14/17)
 => [internal] load build definition from Dockerfile                                                                                                                                                 0.0s
 => => transferring dockerfile: 1.08kB                                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/node:12.20.2                                                                                                                                      1.9s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                          0.0s
 => [internal] load build context                                                                                                                                                                    1.0s
 => => transferring context: 12.72MB                                                                                                                                                                 1.0s
 => [ 1/12] FROM docker.io/library/node:12.20.2@sha256:0140c4e17aa1f3fd78b939e3c7ac45accdd5274d0194046b484029a5e46b9db6                                                                             38.6s
 => => resolve docker.io/library/node:12.20.2@sha256:0140c4e17aa1f3fd78b939e3c7ac45accdd5274d0194046b484029a5e46b9db6                                                                                0.0s
 => => sha256:0140c4e17aa1f3fd78b939e3c7ac45accdd5274d0194046b484029a5e46b9db6 776B / 776B                                                                                                           0.0s
 => => sha256:2571706a0e9a90a55ea51746239ff8acd489e5c2ce2f119273245ccbc0a94392 2.21kB / 2.21kB                                                                                                       0.0s
 => => sha256:3aab5c2e02a68fcfa5e8c766e1689c6790580f0d51ee647ab67ea57b21fa6dc2 7.83kB / 7.83kB                                                                                                       0.0s
 => => sha256:296c9f0bf5f2cf24e87bc5abd674fc486e8df419d4aa2d362453f64d38900504 43.18MB / 43.18MB                                                                                                    10.1s
 => => sha256:84d546321c8e11789c75187b5b592633207519d75f96e8f03e8378d2da4a72a9 10.18MB / 10.18MB                                                                                                     3.9s
 => => sha256:f91c8ffe219846d18819503633eb252121c21cd20dbff74278b85c4029370992 4.10MB / 4.10MB                                                                                                       1.8s
 => => sha256:df8d698654f0ee6c5be4a19593a2d7a793c4bed9cb10de0c87d1d1c2ce6ba368 47.73MB / 47.73MB                                                                                                    11.2s
 => => sha256:eb8f7931e7aa1d31b83a8db251eb9107d989c9244f8bd7a542788aef3b6d1975 201.71MB / 201.71MB                                                                                                  32.0s
 => => sha256:6516b36f67a70cc6094778e92c2002789a89825b2769c9d5ce9f6427c5c813c2 4.20kB / 4.20kB                                                                                                      10.4s
 => => extracting sha256:296c9f0bf5f2cf24e87bc5abd674fc486e8df419d4aa2d362453f64d38900504                                                                                                            2.3s
 => => sha256:8592970063e59260afa874fb5f28a75d3e4742e7edaaafc1ba690c492e2039d4 23.70MB / 23.70MB                                                                                                    15.0s
 => => sha256:934b7a74b39bb36b47f580e3c33386d8edf20b9f9bc885442b1e78875d253ddf 2.38MB / 2.38MB                                                                                                      11.8s
 => => sha256:68a1166726ff6c90bb9e39a88d2245a71adb142bc16a8731e84ac31b4762ccbc 292B / 292B                                                                                                          12.1s
 => => extracting sha256:84d546321c8e11789c75187b5b592633207519d75f96e8f03e8378d2da4a72a9                                                                                                            0.7s
 => => extracting sha256:f91c8ffe219846d18819503633eb252121c21cd20dbff74278b85c4029370992                                                                                                            0.2s
 => => extracting sha256:df8d698654f0ee6c5be4a19593a2d7a793c4bed9cb10de0c87d1d1c2ce6ba368                                                                                                            3.1s
 => => extracting sha256:eb8f7931e7aa1d31b83a8db251eb9107d989c9244f8bd7a542788aef3b6d1975                                                                                                            5.2s
 => => extracting sha256:6516b36f67a70cc6094778e92c2002789a89825b2769c9d5ce9f6427c5c813c2                                                                                                            0.0s
 => => extracting sha256:8592970063e59260afa874fb5f28a75d3e4742e7edaaafc1ba690c492e2039d4                                                                                                            0.8s
 => => extracting sha256:934b7a74b39bb36b47f580e3c33386d8edf20b9f9bc885442b1e78875d253ddf                                                                                                            0.1s
 => => extracting sha256:68a1166726ff6c90bb9e39a88d2245a71adb142bc16a8731e84ac31b4762ccbc                                                                                                            0.0s
 => [ 2/12] RUN apt-get update && apt-get install -y     iproute2 ethtool iputils-ping iperf3 python3 lsof tcpdump net-tools                                                                         5.7s
 => [ 3/12] ADD run-in-vnc.sh /opt/lib/                                                                                                                                                              0.0s
 => [ 4/12] RUN if [ -n "true" ] ; then apt-get install -y tigervnc-standalone-server ratpoison ; else echo "No VNC for you" ; fi                                                                   13.1s
 => [ 5/12] RUN apt-get install -y curl build-essential                                                                                                                                              1.9s
 => [ 6/12] RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs     | sh -s -- --default-toolchain nightly -y                                                                             26.2s
 => [ 7/12] ADD rush /opt/lib/rush                                                                                                                                                                   0.1s
 => [ 8/12] WORKDIR /opt/lib/rush                                                                                                                                                                    0.0s
 => ERROR [ 9/12] RUN cargo build --release                                                                                                                                                         12.7s
------
 > [ 9/12] RUN cargo build --release:
#14 0.695    Compiling libc v0.2.68
#14 0.695    Compiling proc-macro2 v1.0.24
#14 0.695    Compiling unicode-xid v0.2.1
#14 0.695    Compiling syn v1.0.60
#14 0.695    Compiling getrandom v0.2.2
#14 0.697    Compiling cfg-if v1.0.0
#14 0.700    Compiling memchr v2.3.3
#14 0.845    Compiling serde_derive v1.0.123
#14 0.873    Compiling ryu v1.0.5
#14 1.092    Compiling serde v1.0.123
#14 1.125    Compiling signal-hook v0.3.6
#14 1.198    Compiling byteorder v1.3.4
#14 1.206    Compiling ppv-lite86 v0.2.10
#14 1.207    Compiling serde_json v1.0.62
#14 1.312    Compiling lazy_static v1.4.0
#14 1.337    Compiling regex-syntax v0.6.17
#14 1.403    Compiling itoa v0.4.7
#14 1.435    Compiling once_cell v1.3.1
#14 1.687    Compiling thread_local v1.0.1
#14 1.854    Compiling aho-corasick v0.7.10
#14 2.162    Compiling quote v1.0.9
#14 2.342    Compiling signal-hook-registry v1.3.0
#14 2.470    Compiling rand_core v0.6.2
#14 2.700    Compiling rand_chacha v0.3.0
#14 3.014    Compiling rand v0.8.3
#14 3.564    Compiling regex v1.3.6
#14 11.58    Compiling rush v0.1.0 (/opt/lib/rush)
#14 12.45 error: cannot find macro `asm` in this scope
#14 12.45    --> src/checksum.rs:151:5
#14 12.45     |
#14 12.45 151 |     asm!("
#14 12.45     |     ^^^
#14 12.45     |
#14 12.45     = note: consider importing one of these items:
#14 12.45             std::arch::asm
#14 12.45             core::arch::asm
#14 12.45
#14 12.61 error: could not compile `rush` due to previous error
------
executor failed running [/bin/sh -c cargo build --release]: exit code: 101
make: *** [image-vnc] Error 1

Steps to reproduce

$ git clone https://github.com/daily-co/synthetic-network.git
$ cd synthetic-network/
$ make run-chrome

Screenshots

System information

I am not familiar with Rust programming. I found this thread that seems surface-similar to the error I received, and so I thought perhaps it was an architecture-specific problem; I am running on arm64 on an M1 Mac. However I see the same error on an x86 Mac.

OS and arch for both systems:

# m1 mac, macOS Monterey 12.1
$ uname -a
Darwin MacBook-Pro.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64
$ docker --version
Docker version 20.10.11, build dea9396

# x86 mac, macOS Monterey 12.0.1
$ uname -a
Darwin Jasons-MacBook-Pro-2.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64_x86_64
$ docker --version
Docker version 20.10.11, build dea9396
@jasonm jasonm added the bug Something isn't working label Jan 18, 2022
@jasonm
Copy link
Contributor Author

jasonm commented Jan 20, 2022

Hi @eugeneia and @vipyne - thanks for what appears to be a super useful project! I'm very new to Rust programming and am not sure how to debug the build error. Could you point me in the right direction? Thanks!

@vipyne
Copy link
Member

vipyne commented Jan 20, 2022

Hi @jasonm , thanks for taking a look. What is the output of $ rustc -V and $ rustup -V ?

@jasonm
Copy link
Contributor Author

jasonm commented Jan 21, 2022

Hi @vipyne thanks for your message! I ended up opening #3 and included my notes below.

Versions of rustc and rustup

The cargo build command is executing as part of building a docker image per the Makefile/Dockerfile in this repo, so here's the version of rustc and rustup from the intermediate docker image layer immediately prior to the failing cargo build command:

~/dev/synthetic-network $ docker run -it --rm 04ca521c91d6 /bin/bash

root@4cb8abbf11ca:/opt/lib/rush# rustc -V
rustc 1.60.0-nightly (5e57faa78 2022-01-19)

root@4cb8abbf11ca:/opt/lib/rush# rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.60.0-nightly (5e57faa78 2022-01-19)`

Here's the full docker build ... command that resulted in this image, so you can see where the 04ca521c91d6 came from.

Looks like the Dockerfile in this repo is always installing the latest nightly build of rust.

Namespacing the asm! macro

I spent a little more time reading the rust-lang/rust#84019 thread I found earlier, and figured I'd try fiddling with the source to see if I could move things forward.

I namespaced the asm! macro and voila! It built! Well, it complained with a warning, but that seems harmless:

Step 11/15 : RUN cargo build --release
 ---> Running in e28fc7c0a3ed
   Compiling libc v0.2.68
(...)
   Compiling rush v0.1.0 (/opt/lib/rush)
warning: the feature `asm` has been stable since 1.59.0 and no longer requires an attribute to enable
 --> src/main.rs:3:12
  |
3 | #![feature(asm)]
  |            ^^^
  |
  = note: `#[warn(stable_features)]` on by default

warning: `rush` (bin "rush") generated 1 warning
    Finished release [optimized] target(s) in 12.60s

De-feature-ing asm

Removing the feature line caused the compilation to succeed with no warnings.

@jasonm
Copy link
Contributor Author

jasonm commented Jan 21, 2022

Fixed with #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants