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

Add new feature to allow building ckb-std using clang as C compiler #67

Merged
merged 2 commits into from
Aug 23, 2023

Conversation

xxuejie
Copy link
Collaborator

@xxuejie xxuejie commented Aug 23, 2023

No description provided.

@xxuejie xxuejie merged commit 4d2c5b5 into nervosnetwork:master Aug 23, 2023
2 checks passed
@xxuejie xxuejie deleted the build-with-clang branch August 23, 2023 03:50
@blckngm
Copy link
Collaborator

blckngm commented Aug 30, 2023

The cc crate allows setting the compiler via the CC or CC_<target> environment variables. Why not support clang with these and https://docs.rs/cc/latest/cc/struct.Tool.html#method.is_like_clang.

@xxuejie
Copy link
Collaborator Author

xxuejie commented Aug 31, 2023

In fact, I did use environment variables including CC, CC_<target> or TARGET_CC to set the compiler to use a lot in the past. I have mixed feelings here: overriding CC can be dangerous since this is also picked up by most C compilers, when the project is rather sophisticated, overriding CC can be quite nasty. For example a secp256k1 dependency would have native C compiler compiling native binary to generate certain constant tables, and one might need to use an external script to make sure the C project is compiled without overriding CC, and only set CC in cargo build.

CC_<target> and TARGET_CC has a nicer story here since they are specific to Rust. But still one needs to remember to set the environment variables in advance.

Having a feature we can use here, IMHO, is actually simpler to some minds, since all you need to do is a simple cargo build, there is no need to setup the environment somehow.

But I do agree it does provide values to support changing compilers via CC, CC_<target> or TARGET_CC, and it makes sense to infer the actual compiler via Tool::is_like_clang, I've prepared a PR for this change here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants