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

[Feature] Improve the compilation of skywalking-rover #12789

Closed
3 tasks done
tsint opened this issue Nov 21, 2024 · 4 comments · Fixed by apache/skywalking-rover#159
Closed
3 tasks done

[Feature] Improve the compilation of skywalking-rover #12789

tsint opened this issue Nov 21, 2024 · 4 comments · Fixed by apache/skywalking-rover#159
Assignees
Labels
agent Language agent related. feature New feature Rover eBPF agent
Milestone

Comments

@tsint
Copy link

tsint commented Nov 21, 2024

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

When compiling skywalking-rover, add buildvcs=false to prevent compilation failures caused by Git in container environments. Additionally, include the flags -tags osusergo,netgo to achieve fully static compilation, avoiding runtime issues caused by incompatible versions of the glibc library.

For more infomation, see:

Use case

No response

Related issues

No response

Are you willing to submit a pull request to implement this on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@tsint tsint added the feature New feature label Nov 21, 2024
@wu-sheng wu-sheng added agent Language agent related. Rover eBPF agent labels Nov 21, 2024
@mrproliu
Copy link
Contributor

  1. For buildvcs=false, could you describe the scenario when it would cause failure? We already use volume mount when building the binary in the container.
  2. For the -tags osusergo,netgo, we already disable the gclib library in https://github.com/apache/skywalking-rover/blob/main/docker/Dockerfile.build#L26. So I think these two tags are not necessary.

@tsint
Copy link
Author

tsint commented Nov 22, 2024

  1. For buildvcs=false, could you describe the scenario when it would cause failure? We already use volume mount when building the binary in the container.
  2. For the -tags osusergo,netgo, we already disable the gclib library in https://github.com/apache/skywalking-rover/blob/main/docker/Dockerfile.build#L26. So I think these two tags are not necessary.
  1. Many scenarios could lead to issues, such as the code directory not being set as a safe.directory, a change in the directory owner. Or the presence of a .git directory in a parent directory, or corruption of the .git directory itself. In short, setting this causes no harm and helps avoid unnecessary compilation failures.
  2. Based on my actual execution of the ldd command, it does not appear to be as you described.
$ ldd bin/skywalking-rover-latest-linux-amd64
        linux-vdso.so.1 (0x00007ffc287e8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faeb7800000)
        /lib64/ld-linux-x86-64.so.2 (0x00007faeb7b93000)

If go tags are added, it becomes noticeably different.

$ ldd bin/skywalking-rover-latest-linux-amd64
        not a dynamic executable

Setting ENV CGO_ENABLED=0 has no effect on Docker's RUN command. Moreover, if CGO_ENABLED=0 is added to the compilation command, importing "c" will result in a compilation failure.

@mrproliu
Copy link
Contributor

Many scenarios could lead to issues, such as the code directory not being set as a safe.directory, a change in the directory owner. Or the presence of a .git directory in a parent directory, or corruption of the .git directory itself. In short, setting this causes no harm and helps avoid unnecessary compilation failures.

Make sense to me, please add this parameter.

Setting ENV CGO_ENABLED=0 has no effect on Docker's RUN command. Moreover, if CGO_ENABLED=0 is added to the compilation command, importing "c" will result in a compilation failure.

Then, we should consider why the CGO_ENABLED is not working?

@tsint
Copy link
Author

tsint commented Nov 22, 2024

Many scenarios could lead to issues, such as the code directory not being set as a safe.directory, a change in the directory owner. Or the presence of a .git directory in a parent directory, or corruption of the .git directory itself. In short, setting this causes no harm and helps avoid unnecessary compilation failures.

Make sense to me, please add this parameter.

Setting ENV CGO_ENABLED=0 has no effect on Docker's RUN command. Moreover, if CGO_ENABLED=0 is added to the compilation command, importing "c" will result in a compilation failure.

Then, we should consider why the CGO_ENABLED is not working?

Sorry, I found that it was my mistake about failure to build a static executable file.
I manually executed make linux inside the container because I didn't want to create an image and push it to the local Docker repository, and also to speed up the compilation process.
Although setting ENV CGO_ENABLED=0 is fine, I would like to add CGO_ENABLED=0 to the build command and also add a generate dependency to the build process. This would make it easier to compile manually inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent Language agent related. feature New feature Rover eBPF agent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants