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

Rust Example #462

Merged
merged 16 commits into from
Feb 27, 2020
Merged

Conversation

blhagadorn
Copy link
Contributor

This adds an example of a simple Rust Hello World on STDOUT using the cc image

@googlebot googlebot added the cla: yes CLAs look good label Feb 13, 2020
@blhagadorn
Copy link
Contributor Author

I felt compelled to do this because I wanted to show the usage of the cc image, FYI

@blhagadorn
Copy link
Contributor Author

@donmccasland

Copy link
Member

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

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

We should probably get someone with some familiarity with rust to review this. But I might as well ask while I'm here:

  1. Are the libraries required for cc enough for rust?
  2. I think you need to include a BUILD file like: https://github.com/GoogleContainerTools/distroless/blob/master/examples/go/BUILD as these examples are built from source.

@blhagadorn
Copy link
Contributor Author

blhagadorn commented Feb 19, 2020

We should probably get someone with some familiarity with rust to review this. But I might as well ask while I'm here:

  1. Are the libraries required for cc enough for rust?

That's a great question, I think libc is all it needs for its basic functions for interfacing with the system library, I/O, networking, etc. rather than having an abstract layer like Golang where syscalls are built into the language. I agree this should definitely get the sign-off from someone much better at a novice like me though.

  1. I think you need to include a BUILD file like: https://github.com/GoogleContainerTools/distroless/blob/master/examples/go/BUILD as these examples are built from source.

Ahh good point, I will work on a BUILD file for Bazel.

@blhagadorn blhagadorn changed the title Rust Example [WIP Do Not Merge] Rust Example Feb 20, 2020
Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This makes sense — the cc/README.md suggests that it's suitable for languages like Rust.

README.md Outdated Show resolved Hide resolved
examples/rust/BUILD Show resolved Hide resolved
@blhagadorn
Copy link
Contributor Author

Alright thanks for the tip @briandealwis , new to Bazel but the documentation helped and I think I have things correct. Ready for review when any of you can!

@blhagadorn blhagadorn changed the title [WIP Do Not Merge] Rust Example Rust Example Feb 24, 2020
@blhagadorn
Copy link
Contributor Author

blhagadorn commented Feb 27, 2020

Are the libraries required for cc enough for rust?

To re-answer this question after research, for this example I think libc is enough for most standard Rust procedures. If there are other dependencies, however, they might need other items.

@briandealwis briandealwis merged commit fa9a428 into GoogleContainerTools:master Feb 27, 2020
@briandealwis
Copy link
Member

Thanks for your contribution!

@blhagadorn
Copy link
Contributor Author

No problem, thanks for reviewing!

@blhagadorn blhagadorn deleted the rust-example branch February 28, 2020 03:27
@CodesInChaos
Copy link

@blhagadorn is there a reason this needs cc and not just base?

@blhagadorn
Copy link
Contributor Author

@CodesInChaos For libcc1 which isn't inside of base, and is sparsely found in different Unix operating systems. See this interesting discussion: rust-lang/rustup#2213 or this masterpiece: https://wiki.alopex.li/LetsBeRealAboutDependencies. Otherwise, users might see this error: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory

However I might be overcomplicating things, is there an alternative?

@CodesInChaos
Copy link

I didn't realize that rust applications link to libgcc at runtime. I thought that only the compiler depends on on it, while applications depend only on glibc.

@blhagadorn
Copy link
Contributor Author

Yeah, I think it's heavily dependent on operation system, too (Linux is of course a spectrum). I might be wrong about this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLAs look good
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants