]> git.proxmox.com Git - rustc.git/blob - debian/README.source
Update upstream source from tag 'upstream/1.25.0+dfsg1'
[rustc.git] / debian / README.source
1 Document by Ximin Luo, Luca Bruno & Sylvestre Ledru
2
3 This source package is unfortunately quite tricky and with several cutting
4 edges, due to the complexity of rust-lang bootstrapping system and the high
5 rate of language changes still ongoing.
6
7 We try to describe here inner packaging details and the reasons behind them.
8
9 If you are looking to help maintain this package, be sure to read the "Notes
10 for package maintainers" section further below.
11
12
13 Embedded libraries
14 ==================
15
16 This source package embeds several external libraries (foeked and managed
17 by rust upstream as git submodules).
18 In early stages, many more libraries were forked/emebedded but we are steadily
19 progressing in splitting them out.
20
21 Here below the remaining ones, with the technical reasons.
22
23 * binaryen from https://github.com/alexcrichton/binaryen.git
24 -> temporary until LLVM lld is available
25 - see issue upstream: TODO waiting for alexcrichton to create one
26
27 * compiler-rt from https://github.com/rust-lang/compiler-rt
28 -> system-wide compiler-rt fails during linkage
29
30 Bug reported upstream, still to be fixed, see:
31 - https://github.com/rust-lang/rust/issues/15054
32 - https://github.com/rust-lang/rust/issues/15708
33
34 As a summary, we plan to:
35 * work with upstream to fix compiler-rt linkage soon.
36
37 -- Sylvestre Ledru <sylvestre@debian.org> Sat, 06 May 2017 13:26:08 +0200
38
39
40 Building from source
41 ====================
42
43 The Debian rustc package will use the system rustc to bootstrap itself from.
44 The system rustc has to be either the previous or the same version as the rustc
45 being built; the build will fail if this is not the case.
46
47 sudo apt-get build-dep ./
48 dpkg-buildpackage
49 # Or, to directly use what's in the Debian FTP archive
50 sudo apt-get build-dep rustc
51 apt-get source --compile rustc
52
53 Alternatively, you may give the "pkg.rustc.dlstage0" DEB_BUILD_PROFILE to
54 instead use the process defined by Rust upstream. This downloads the "official"
55 stage0 compiler for the version being built from rust-lang.org. At the time of
56 writing "official" means "the previous stable version".
57
58 sudo apt-get build-dep -P pkg.rustc.dlstage0 ./
59 dpkg-buildpackage
60 # Or, to directly use what's in the Debian FTP archive
61 sudo apt-get build-dep -P pkg.rustc.dlstage0 rustc
62 apt-get source --compile -P pkg.rustc.dlstage0 rustc
63
64 After [1] is fixed, both of these should in theory give identical results.
65
66 If neither of these options are acceptable to you, e.g. because your distro
67 does not have rustc already and your build process cannot access the network,
68 see "Bootstrapping" below.
69
70 [1] https://github.com/rust-lang/rust/issues/34902
71
72
73 Bootstrapping
74 =============
75
76 To bootstrap rustc on a distro that does not have it or cargo available on any
77 architecture (so cross-compiling is not an option) you can run `debian/rules
78 source_orig-stage0`. This creates a .dsc that does not Build-Depend on rustc or
79 cargo. Instead, it includes an extra orig-stage0 source tarball that contains
80 the official stage0 compiler, pre-downloaded from rust-lang.org so that your
81 build daemons don't need to access the network during the build.
82
83 debian/rules source_orig-stage0
84 # Follow the final manual instructions that it outputs. Then:
85 sbuild ../rustc_*.dsc && dput ../rustc_*.dsc
86
87 To only bootstrap specific architectures, run this instead:
88
89 upstream_bootstrap_arch="arm64 armhf" debian/rules source_orig-stage0
90
91 This way, other architectures will be omitted from the orig-stage0 tarball. You
92 might want to do this e.g. if these other architectures are already present in
93 your distro, but the $upstream_bootstrap_arch ones are not yet present.
94
95 Notes
96 -----
97
98 The approach bundles the upstream bootstrapping binaries inside the Debian
99 source package. This is a nasty hack that stretches the definition of "source
100 package", but has a few advantages explained below.
101
102 The traditional Debian way of bootstrapping compilers - and other distros have
103 similar approaches - is some variant of the following:
104
105 1. A developer locally installs some upstream bootstrapping binaries.
106 2. They locally build a Debian package, using these binaries as undeclared
107 build dependencies.
108 3. They upload these binary packages to Debian, which can be used as declared
109 Build-Depends in the future, including by the same package.
110
111 The problem with this is, Debian does not have any policy nor infrastructure
112 that can try to reproduce what this developer supposedly did.
113
114 Using bootstrapping binary blobs *at some point of the process* is unavoidable.
115 Rather than pretending we didn't do this, it is better to record *which blobs*
116 we used, so it can be audited later. If we bundle non-Debian build-dependencies
117 inside the source package, then we can do a *source-only upload*, and the
118 building of the binary packages can be done by the normal build infrastructure.
119
120 If the build process is reproducible [1] then we can be sure that *you* (as the
121 developer that prepared the source-only upload) didn't backdoor the binaries,
122 nor did the build daemons even if they were compromised during the build.
123
124 The bootstrapping binaries may still have been backdoored, but this is true in
125 both scenarios. So our arrangement is still a strict improvement in security,
126 because it reduces the set of "things that may have been backdoored". Also,
127 more people use the upstream binaries than the "magical original Debian
128 package", so backdoors have a greater chance of being detected in the former.
129
130 In the long run, this process is laying the foundations for doing Diverse
131 Double-Compilation [2], where we use *many independent* bootstrapping binaries
132 to reproduce bit-for-bit identical output compilers, giving confidence that
133 nothing was backdoored along the way.
134
135 [1] The build process for rustc is currently *not* reproducible but we're
136 working towards it. https://github.com/rust-lang/rust/issues/34902
137 [2] http://www.dwheeler.com/trusting-trust/
138
139
140 Maintaining this package
141 ========================
142
143 Import of a new upstream version
144 --------------------------------
145
146 # Make sure you apply the patch mentioned in #855464 to /usr/bin/mk-origtargz
147
148 $ sudo mk-build-deps -irt 'aptitude -R'
149 $ uscan --verbose
150 $ ver=UPDATE-ME # whatever it is, X.YY.0 or X.YY.0~beta probably
151 $ tar xf ../rustc-${ver/\~/-}-src.tar.xz && ( cd rustc-${ver/*~*/beta}-src/ && ../debian/prune-unused-deps ) && rm -rf rustc-${ver/*~*/beta}-src/
152 # ^ If this fails, you probably need to refresh patches or edit debian/prune-unused-deps
153 $ git commit -m "Update Files-Excluded for new upstream version ${ver/\~/-}" debian/copyright
154 $ uscan --verbose # yes, again, to pick up the new Files-Excluded stuff
155
156 # Keep running this and follow its instructions, until it gives no output:
157 $ debian/check-orig-suspicious.sh $ver
158 # When you are satisfied with the above, proceed:
159
160 $ gbp import-orig ../rustc_$ver+dfsg1.orig.tar.xz
161 $ dch -v $ver+dfsg1-1 -m "New upstream release."
162 $ debian/rules update-version
163 # might also need to bump the version of the cargo Build-Depends
164 # then refresh patches, etc etc
165 # Use /usr/share/cargo/guess-crate-copyright to help update d/copyright quickly
166
167 # If you need to repack again, bump the 'repacksuffix' in d/watch then run
168 $ uscan --verbose --force-download
169 # This will do a local repack using the new Files-Excluded rules, without
170 # redownloading the orig tarball (despite the slightly misleading flag).
171
172
173 Proceeding after build failure
174 ------------------------------
175
176 If your build fails, don't run `./x.py` directly as that will detect it's being
177 run with different settings, and run the build from scratch all over again.
178 overwriting all intermediate files. Instead, do:
179
180 $ debian/rules run_rustbuild X_CMD="build|test|install" X_FLAGS="whatever"
181
182 Hopefully, this will directly proceed to the step that failed, without
183 rebuilding everything in between.
184
185
186 Comparing Debian rustc vs upstream rustc
187 ----------------------------------------
188
189 This package does things the Debian way, which differs significantly from
190 upstream practices. If you find a bug, you might want to check if it is present
191 in the upstream package. Run "debian/rules debian/config.toml" to generate our
192 config.toml that you can then use in an unpacked upstream directory.
193
194 This will configure it in a "halfway" style between upstream and Debian.
195 Specifically, it will not build LLVM nor download stuff from crates.io, yet
196 Debian patches are *not* applied. These specific settings were chosen as a
197 tradeoff between convenience vs being close to what upstream does - so that the
198 chances of a bug here being a genuine upstream issue rather than a Debian bug,
199 is much higher. Also, with the exception of LLVM, these are non-default modes
200 *supported by* upstream so they would be happy to receive bug reports about it
201 even if your issue only occurs here.
202
203 OTOH if you need to test a completely clean upstream build, including all the
204 annoying stuff like building LLVM and downloading dependencies from crates.io,
205 simply unpack the tarball and run `./configure && ./x.py build` etc as normal.
206 This can be useful for confirming that an issue is caused by Debian's LLVM.
207
208 If you need to test a LLVM patch, do something like this:
209
210 # build your patched LLVM debs, then:
211 $ mkdir -p llvm-destdir && cd llvm-destdir
212 $ ver=4.0; VERSION=FIXME
213 $ for i in llvm-$ver llvm-$ver-dev llvm-$ver-runtime llvm-$ver-tools libllvm$ver; do \
214 dpkg -x ../"$i"_*${VERSION}_*.deb .; done
215 $ cd ../rustc
216 $ debian/rules LLVM_DESTDIR=$PWD/../llvm-destdir build
217
218 If you need to test a patch to the stage0 rustc, do something like this:
219
220 # build your patched rustc debs or upstream rustc, then:
221 $ mkdir -p rust-destdir && cd rust-destdir
222 $ ver=1.20; VERSION=FIXME;
223 $ for i in rustc libstd-rust-$ver libstd-rust-dev; do \
224 dpkg -x ../"$i"_*${VERSION}_*.deb .; done
225 $ cd ../rustc
226 $ debian/rules RUST_DESTDIR=$PWD/../rust-destdir build
227
228
229 Useful links
230 ------------
231
232 The Fedora rust team is more active than the Debian one. Here are their links:
233
234 Source code
235 https://src.fedoraproject.org/cgit/rpms/rust.git/tree/
236
237 Binary packages and test logs
238 https://kojipkgs.fedoraproject.org//packages/rust/
239 If the same test fails both on Fedora and Debian it's a good indication that
240 we're not Doing It Wrong and can file a valid bug upstream.
241
242 Package metadata
243 https://admin.fedoraproject.org/pkgdb/package/rpms/rust/