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 a Cargo-based build system to replace the Makefiles #27003

Closed
wants to merge 22 commits into from
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e645ed5
Add Cargo-based build system
cl91 Jul 13, 2015
37755fe
Fix compiletest run-pass fds-are-cloexec
cl91 Jul 13, 2015
6af9387
Add lang_items to librustc_bitflags
cl91 Jul 13, 2015
969c974
Slience warnings when running cargo test on crates
cl91 Jul 13, 2015
4f96077
Update .gitignore
cl91 Jul 13, 2015
6042556
Make build.sh executable
cl91 Jul 13, 2015
92fae85
Fix compilation of librustc_llvm under Cargo
cl91 Jul 13, 2015
c0fe709
Fix doctests of libgetops, liblog, librustc, libsyntax, and librustdoc
cl91 Jul 13, 2015
769b18c
Update README.md to include instructions on building with Cargo
cl91 Jul 13, 2015
85c3ade
Update compiler-rt
cl91 Jul 13, 2015
f47c848
Add ArchiveWrapper.cpp when building rustllvm
cl91 Jul 13, 2015
cdcc1ac
Make build_llvm.py and build_rust.py compatible with Python3
cl91 Jul 14, 2015
bc8d465
Fix year in copyright notice
cl91 Jul 14, 2015
c7bbd39
Add trailing '\n' in src/compiletest/Cargo.toml
cl91 Jul 14, 2015
49a0466
Add from __future__ import print_function
cl91 Jul 14, 2015
a7e0eb8
Use python2 instead of python in librustc_llvm/build.rs
cl91 Jul 14, 2015
6cab349
Detect gdb version and feed into compiletest
cl91 Jul 14, 2015
70858dc
Fix .gitignore
cl91 Jul 15, 2015
2a795be
Refactor build_rust_stagei into build_rust_stage
cl91 Jul 14, 2015
4b59341
Remove LTO for release builds. Remove opt-level=1 for debug builds.
cl91 Jul 15, 2015
ff8b83f
Link `rustc` and `rustdoc` dynamically rather than statically
cl91 Jul 15, 2015
90f55a7
Remove `struct Triple` in `build_helper::cc`
cl91 Jul 15, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -93,3 +93,7 @@ tmp.*.rs
version.md
version.ml
version.texi
*.racertmp
Cargo.lock
target
!/src/librustc_back/target
Copy link
Member

Choose a reason for hiding this comment

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

This can probably be refactored to just:

Cargo.lock
target
!src/librustc_back/target

55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,59 @@ Read ["Installing Rust"] from [The Book].

## Building from Source

Starting from `e645ed59` the Rust Build System is being converted to use
Copy link
Member

Choose a reason for hiding this comment

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

Before we get experience with using Cargo I don't think we want to mention it so prominently in the README. I suspect there will be a long tail of many minor bugs to fix, and we can always add this info later on down the road.

Cargo. The new build system is supposed to replace the old Makefile-based
build system once it is mature enough. It is encouraged to use the new build
system whenever possible as the Makefile-based system is marked for deletion
in the future.

To build the compiler,

1. Make sure you have installed the dependencies:

* `g++` 4.7 or `clang++` 3.x
* `python` 2.7 or later (but not 3.x)
Copy link
Member

Choose a reason for hiding this comment

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

3.x is released so long ago, that it doesn’t make sense to support 2.x only. That’s something that can be fixed later, of course.

Copy link
Author

Choose a reason for hiding this comment

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

The LLVM build system requires Python2, so you need python2 to compile LLVM. The python scripts in the Rust source repo are compatible with both versions.

* `git`

On a Unix-based system (Linux/Mac) you also need:

* GNU `make` 3.81 or later

2. Download the latest nightly build of Rust, and install it.

On Unix-based systems, you can use the `multirust` tool to do this.

3. Clone the [source] with `git`:

```sh
$ git clone https://github.com/rust-lang/rust.git
$ cd rust
```

[source]: https://github.com/rust-lang/rust

4. Update the git submodules within the source repository:

```sh
$ git submodule init
$ git submodule update
```

5. On a Unix-based system, run

```sh
$ ./build.sh
```

On Windows, open a (normal) command line window and run

```
python src\etc\build_rust.py
```


## Building from Source with the Makefile-based Build System

1. Make sure you have installed the dependencies:

* `g++` 4.7 or `clang++` 3.x
@@ -55,7 +108,7 @@ Read ["Installing Rust"] from [The Book].

[Cargo]: https://github.com/rust-lang/cargo

### Building on Windows
### Building on Windows with the Makefile-based Build System

[MSYS2](http://msys2.github.io/) can be used to easily build Rust on Windows:

3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python src/etc/build_rust.py $@
Copy link
Member

Choose a reason for hiding this comment

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

This will positively not work on any systems where python == python3 == python3.*.

Copy link
Author

Choose a reason for hiding this comment

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

I think the only python2 feature that was used in build_rust.py and build_llvm.py is the print statement. I have changed them to print() which is available in both python2 and python3. This should make the scripts work with either version.

Copy link
Member

Choose a reason for hiding this comment

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

I’d just call python2 here, honestly, unless you’re absolutely sure it will work on both python3 and python2.

Copy link
Member

Choose a reason for hiding this comment

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

from __future__ import print_function (and other future imports) is a good way to support both 2.7 and 3.*.

Copy link
Author

Choose a reason for hiding this comment

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

@nagisa @huonw I ran the 2to3 tool and added from __future__ import print_function. I tested against both python 2.7 and 3.4 and it works on both versions.

Copy link
Member

Choose a reason for hiding this comment

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

To keep the experience consistent across platforms I'd be fine just removing this small shell script (or moving a python script to the top of the project)

8 changes: 8 additions & 0 deletions src/build_helper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "build_helper"
version = "0.1.0"
authors = ["Chang Liu <cliu712@aucklanduni.ac.nz>"]

[lib]
name = "build_helper"
path = "lib.rs"
Loading