Skip to content

Commit bef48a2

Browse files
amanda-taittamird
authored andcommitted
Add fuchsia support
Allow nix to compile on Fuchsia by conditionally avoiding libc functionality that does not exist for Fuchsia.
1 parent 1d43b2b commit bef48a2

16 files changed

+221
-110
lines changed

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ matrix:
106106
- . $HOME/.cargo/env
107107
- cargo build --all-targets
108108

109+
# Fuchsia doesn't have external CI support, so we'll just make sure things compile
110+
- language: generic
111+
name: fuchsia
112+
script:
113+
- curl --proto '=https' --tlsv1.2 -sSf --output rustup.sh https://sh.rustup.rs
114+
- sh rustup.sh -y --profile=minimal --default-toolchain 1.36.0 --target x86_64-fuchsia
115+
- . $HOME/.cargo/env
116+
- cargo build --target x86_64-fuchsia
117+
- cargo test --target x86_64-fuchsia --no-run
118+
109119
before_install: set -e
110120

111121
install:

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88

99
- Added `mremap` (#[1306](https://github.com/nix-rust/nix/pull/1306))
1010

11+
- Added limited Fuchsia support (#[1285](https://github.com/nix-rust/nix/pull/1285))
1112
### Changed
1213
### Fixed
1314

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ targets = [
2626
"x86_64-unknown-openbsd",
2727
"x86_64-unknown-netbsd",
2828
"x86_64-unknown-dragonfly",
29+
"x86_64-fuchsia",
2930
"x86_64-unknown-redox"
3031
]
3132

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Tier 2:
8282
* x86_64-unknown-netbsd
8383

8484
Tier 3:
85+
* x86_64-fuchsia
8586
* x86_64-unknown-redox
8687

8788
## Usage

src/errno.rs

+128-64
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ cfg_if! {
2020
}
2121
} else if #[cfg(any(target_os = "linux",
2222
target_os = "redox",
23-
target_os = "dragonfly"))] {
23+
target_os = "dragonfly",
24+
target_os = "fuchsia"))] {
2425
unsafe fn errno_location() -> *mut c_int {
2526
libc::__errno_location()
2627
}
@@ -188,192 +189,254 @@ fn desc(errno: Errno) -> &'static str {
188189
EHOSTDOWN => "Host is down",
189190
EHOSTUNREACH => "No route to host",
190191

191-
#[cfg(any(target_os = "linux", target_os = "android"))]
192+
#[cfg(any(target_os = "linux", target_os = "android",
193+
target_os = "fuchsia"))]
192194
ECHRNG => "Channel number out of range",
193195

194-
#[cfg(any(target_os = "linux", target_os = "android"))]
196+
#[cfg(any(target_os = "linux", target_os = "android",
197+
target_os = "fuchsia"))]
195198
EL2NSYNC => "Level 2 not synchronized",
196199

197-
#[cfg(any(target_os = "linux", target_os = "android"))]
200+
#[cfg(any(target_os = "linux", target_os = "android",
201+
target_os = "fuchsia"))]
198202
EL3HLT => "Level 3 halted",
199203

200-
#[cfg(any(target_os = "linux", target_os = "android"))]
204+
#[cfg(any(target_os = "linux", target_os = "android",
205+
target_os = "fuchsia"))]
201206
EL3RST => "Level 3 reset",
202207

203-
#[cfg(any(target_os = "linux", target_os = "android"))]
208+
#[cfg(any(target_os = "linux", target_os = "android",
209+
target_os = "fuchsia"))]
204210
ELNRNG => "Link number out of range",
205211

206-
#[cfg(any(target_os = "linux", target_os = "android"))]
212+
#[cfg(any(target_os = "linux", target_os = "android",
213+
target_os = "fuchsia"))]
207214
EUNATCH => "Protocol driver not attached",
208215

209-
#[cfg(any(target_os = "linux", target_os = "android"))]
216+
#[cfg(any(target_os = "linux", target_os = "android",
217+
target_os = "fuchsia"))]
210218
ENOCSI => "No CSI structure available",
211219

212-
#[cfg(any(target_os = "linux", target_os = "android"))]
220+
#[cfg(any(target_os = "linux", target_os = "android",
221+
target_os = "fuchsia"))]
213222
EL2HLT => "Level 2 halted",
214223

215-
#[cfg(any(target_os = "linux", target_os = "android"))]
224+
#[cfg(any(target_os = "linux", target_os = "android",
225+
target_os = "fuchsia"))]
216226
EBADE => "Invalid exchange",
217227

218-
#[cfg(any(target_os = "linux", target_os = "android"))]
228+
#[cfg(any(target_os = "linux", target_os = "android",
229+
target_os = "fuchsia"))]
219230
EBADR => "Invalid request descriptor",
220231

221-
#[cfg(any(target_os = "linux", target_os = "android"))]
232+
#[cfg(any(target_os = "linux", target_os = "android",
233+
target_os = "fuchsia"))]
222234
EXFULL => "Exchange full",
223235

224-
#[cfg(any(target_os = "linux", target_os = "android"))]
236+
#[cfg(any(target_os = "linux", target_os = "android",
237+
target_os = "fuchsia"))]
225238
ENOANO => "No anode",
226239

227-
#[cfg(any(target_os = "linux", target_os = "android"))]
240+
#[cfg(any(target_os = "linux", target_os = "android",
241+
target_os = "fuchsia"))]
228242
EBADRQC => "Invalid request code",
229243

230-
#[cfg(any(target_os = "linux", target_os = "android"))]
244+
#[cfg(any(target_os = "linux", target_os = "android",
245+
target_os = "fuchsia"))]
231246
EBADSLT => "Invalid slot",
232247

233-
#[cfg(any(target_os = "linux", target_os = "android"))]
248+
#[cfg(any(target_os = "linux", target_os = "android",
249+
target_os = "fuchsia"))]
234250
EBFONT => "Bad font file format",
235251

236-
#[cfg(any(target_os = "linux", target_os = "android"))]
252+
#[cfg(any(target_os = "linux", target_os = "android",
253+
target_os = "fuchsia"))]
237254
ENOSTR => "Device not a stream",
238255

239-
#[cfg(any(target_os = "linux", target_os = "android"))]
256+
#[cfg(any(target_os = "linux", target_os = "android",
257+
target_os = "fuchsia"))]
240258
ENODATA => "No data available",
241259

242-
#[cfg(any(target_os = "linux", target_os = "android"))]
260+
#[cfg(any(target_os = "linux", target_os = "android",
261+
target_os = "fuchsia"))]
243262
ETIME => "Timer expired",
244263

245-
#[cfg(any(target_os = "linux", target_os = "android"))]
264+
#[cfg(any(target_os = "linux", target_os = "android",
265+
target_os = "fuchsia"))]
246266
ENOSR => "Out of streams resources",
247267

248-
#[cfg(any(target_os = "linux", target_os = "android"))]
268+
#[cfg(any(target_os = "linux", target_os = "android",
269+
target_os = "fuchsia"))]
249270
ENONET => "Machine is not on the network",
250271

251-
#[cfg(any(target_os = "linux", target_os = "android"))]
272+
#[cfg(any(target_os = "linux", target_os = "android",
273+
target_os = "fuchsia"))]
252274
ENOPKG => "Package not installed",
253275

254-
#[cfg(any(target_os = "linux", target_os = "android"))]
276+
#[cfg(any(target_os = "linux", target_os = "android",
277+
target_os = "fuchsia"))]
255278
EREMOTE => "Object is remote",
256279

257-
#[cfg(any(target_os = "linux", target_os = "android"))]
280+
#[cfg(any(target_os = "linux", target_os = "android",
281+
target_os = "fuchsia"))]
258282
ENOLINK => "Link has been severed",
259283

260-
#[cfg(any(target_os = "linux", target_os = "android"))]
284+
#[cfg(any(target_os = "linux", target_os = "android",
285+
target_os = "fuchsia"))]
261286
EADV => "Advertise error",
262287

263-
#[cfg(any(target_os = "linux", target_os = "android"))]
288+
#[cfg(any(target_os = "linux", target_os = "android",
289+
target_os = "fuchsia"))]
264290
ESRMNT => "Srmount error",
265291

266-
#[cfg(any(target_os = "linux", target_os = "android"))]
292+
#[cfg(any(target_os = "linux", target_os = "android",
293+
target_os = "fuchsia"))]
267294
ECOMM => "Communication error on send",
268295

269-
#[cfg(any(target_os = "linux", target_os = "android"))]
296+
#[cfg(any(target_os = "linux", target_os = "android",
297+
target_os = "fuchsia"))]
270298
EPROTO => "Protocol error",
271299

272-
#[cfg(any(target_os = "linux", target_os = "android"))]
300+
#[cfg(any(target_os = "linux", target_os = "android",
301+
target_os = "fuchsia"))]
273302
EMULTIHOP => "Multihop attempted",
274303

275-
#[cfg(any(target_os = "linux", target_os = "android"))]
304+
#[cfg(any(target_os = "linux", target_os = "android",
305+
target_os = "fuchsia"))]
276306
EDOTDOT => "RFS specific error",
277307

278-
#[cfg(any(target_os = "linux", target_os = "android"))]
308+
#[cfg(any(target_os = "linux", target_os = "android",
309+
target_os = "fuchsia"))]
279310
EBADMSG => "Not a data message",
280311

281-
#[cfg(any(target_os = "linux", target_os = "android"))]
312+
#[cfg(any(target_os = "linux", target_os = "android",
313+
target_os = "fuchsia"))]
282314
EOVERFLOW => "Value too large for defined data type",
283315

284-
#[cfg(any(target_os = "linux", target_os = "android"))]
316+
#[cfg(any(target_os = "linux", target_os = "android",
317+
target_os = "fuchsia"))]
285318
ENOTUNIQ => "Name not unique on network",
286319

287-
#[cfg(any(target_os = "linux", target_os = "android"))]
320+
#[cfg(any(target_os = "linux", target_os = "android",
321+
target_os = "fuchsia"))]
288322
EBADFD => "File descriptor in bad state",
289323

290-
#[cfg(any(target_os = "linux", target_os = "android"))]
324+
#[cfg(any(target_os = "linux", target_os = "android",
325+
target_os = "fuchsia"))]
291326
EREMCHG => "Remote address changed",
292327

293-
#[cfg(any(target_os = "linux", target_os = "android"))]
328+
#[cfg(any(target_os = "linux", target_os = "android",
329+
target_os = "fuchsia"))]
294330
ELIBACC => "Can not access a needed shared library",
295331

296-
#[cfg(any(target_os = "linux", target_os = "android"))]
332+
#[cfg(any(target_os = "linux", target_os = "android",
333+
target_os = "fuchsia"))]
297334
ELIBBAD => "Accessing a corrupted shared library",
298335

299-
#[cfg(any(target_os = "linux", target_os = "android"))]
336+
#[cfg(any(target_os = "linux", target_os = "android",
337+
target_os = "fuchsia"))]
300338
ELIBSCN => ".lib section in a.out corrupted",
301339

302-
#[cfg(any(target_os = "linux", target_os = "android"))]
340+
#[cfg(any(target_os = "linux", target_os = "android",
341+
target_os = "fuchsia"))]
303342
ELIBMAX => "Attempting to link in too many shared libraries",
304343

305-
#[cfg(any(target_os = "linux", target_os = "android"))]
344+
#[cfg(any(target_os = "linux", target_os = "android",
345+
target_os = "fuchsia"))]
306346
ELIBEXEC => "Cannot exec a shared library directly",
307347

308-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
348+
#[cfg(any(target_os = "linux", target_os = "android",
349+
target_os = "fuchsia", target_os = "openbsd"))]
309350
EILSEQ => "Illegal byte sequence",
310351

311-
#[cfg(any(target_os = "linux", target_os = "android"))]
352+
#[cfg(any(target_os = "linux", target_os = "android",
353+
target_os = "fuchsia"))]
312354
ERESTART => "Interrupted system call should be restarted",
313355

314-
#[cfg(any(target_os = "linux", target_os = "android"))]
356+
#[cfg(any(target_os = "linux", target_os = "android",
357+
target_os = "fuchsia"))]
315358
ESTRPIPE => "Streams pipe error",
316359

317-
#[cfg(any(target_os = "linux", target_os = "android"))]
360+
#[cfg(any(target_os = "linux", target_os = "android",
361+
target_os = "fuchsia"))]
318362
EUSERS => "Too many users",
319363

320364
#[cfg(any(target_os = "linux", target_os = "android",
321-
target_os = "netbsd", target_os = "redox"))]
365+
target_os = "fuchsia", target_os = "netbsd",
366+
target_os = "redox"))]
322367
EOPNOTSUPP => "Operation not supported on transport endpoint",
323368

324-
#[cfg(any(target_os = "linux", target_os = "android"))]
369+
#[cfg(any(target_os = "linux", target_os = "android",
370+
target_os = "fuchsia"))]
325371
ESTALE => "Stale file handle",
326372

327-
#[cfg(any(target_os = "linux", target_os = "android"))]
373+
#[cfg(any(target_os = "linux", target_os = "android",
374+
target_os = "fuchsia"))]
328375
EUCLEAN => "Structure needs cleaning",
329376

330-
#[cfg(any(target_os = "linux", target_os = "android"))]
377+
#[cfg(any(target_os = "linux", target_os = "android",
378+
target_os = "fuchsia"))]
331379
ENOTNAM => "Not a XENIX named type file",
332380

333-
#[cfg(any(target_os = "linux", target_os = "android"))]
381+
#[cfg(any(target_os = "linux", target_os = "android",
382+
target_os = "fuchsia"))]
334383
ENAVAIL => "No XENIX semaphores available",
335384

336-
#[cfg(any(target_os = "linux", target_os = "android"))]
385+
#[cfg(any(target_os = "linux", target_os = "android",
386+
target_os = "fuchsia"))]
337387
EISNAM => "Is a named type file",
338388

339-
#[cfg(any(target_os = "linux", target_os = "android"))]
389+
#[cfg(any(target_os = "linux", target_os = "android",
390+
target_os = "fuchsia"))]
340391
EREMOTEIO => "Remote I/O error",
341392

342-
#[cfg(any(target_os = "linux", target_os = "android"))]
393+
#[cfg(any(target_os = "linux", target_os = "android",
394+
target_os = "fuchsia"))]
343395
EDQUOT => "Quota exceeded",
344396

345397
#[cfg(any(target_os = "linux", target_os = "android",
346-
target_os = "openbsd", target_os = "dragonfly"))]
398+
target_os = "fuchsia", target_os = "openbsd",
399+
target_os = "dragonfly"))]
347400
ENOMEDIUM => "No medium found",
348401

349-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
402+
#[cfg(any(target_os = "linux", target_os = "android",
403+
target_os = "fuchsia", target_os = "openbsd"))]
350404
EMEDIUMTYPE => "Wrong medium type",
351405

352-
#[cfg(any(target_os = "linux", target_os = "android"))]
406+
#[cfg(any(target_os = "linux", target_os = "android",
407+
target_os = "fuchsia"))]
353408
ECANCELED => "Operation canceled",
354409

355-
#[cfg(any(target_os = "linux", target_os = "android"))]
410+
#[cfg(any(target_os = "linux", target_os = "android",
411+
target_os = "fuchsia"))]
356412
ENOKEY => "Required key not available",
357413

358-
#[cfg(any(target_os = "linux", target_os = "android"))]
414+
#[cfg(any(target_os = "linux", target_os = "android",
415+
target_os = "fuchsia"))]
359416
EKEYEXPIRED => "Key has expired",
360417

361-
#[cfg(any(target_os = "linux", target_os = "android"))]
418+
#[cfg(any(target_os = "linux", target_os = "android",
419+
target_os = "fuchsia"))]
362420
EKEYREVOKED => "Key has been revoked",
363421

364-
#[cfg(any(target_os = "linux", target_os = "android"))]
422+
#[cfg(any(target_os = "linux", target_os = "android",
423+
target_os = "fuchsia"))]
365424
EKEYREJECTED => "Key was rejected by service",
366425

367-
#[cfg(any(target_os = "linux", target_os = "android"))]
426+
#[cfg(any(target_os = "linux", target_os = "android",
427+
target_os = "fuchsia"))]
368428
EOWNERDEAD => "Owner died",
369429

370-
#[cfg(any(target_os = "linux", target_os = "android"))]
430+
#[cfg(any(target_os = "linux", target_os = "android",
431+
target_os = "fuchsia"))]
371432
ENOTRECOVERABLE => "State not recoverable",
372433

373-
#[cfg(all(target_os = "linux", not(target_arch="mips")))]
434+
#[cfg(any(all(target_os = "linux", not(target_arch="mips")),
435+
target_os = "fuchsia"))]
374436
ERFKILL => "Operation not possible due to RF-kill",
375437

376-
#[cfg(all(target_os = "linux", not(target_arch="mips")))]
438+
#[cfg(any(all(target_os = "linux", not(target_arch="mips")),
439+
target_os = "fuchsia"))]
377440
EHWPOISON => "Memory page has hardware error",
378441

379442
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -567,7 +630,8 @@ fn desc(errno: Errno) -> &'static str {
567630
}
568631
}
569632

570-
#[cfg(any(target_os = "linux", target_os = "android"))]
633+
#[cfg(any(target_os = "linux", target_os = "android",
634+
target_os = "fuchsia"))]
571635
mod consts {
572636
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
573637
#[repr(i32)]

src/features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod os {
9797
#[cfg(any(target_os = "macos", target_os = "freebsd",
9898
target_os = "dragonfly", target_os = "ios",
9999
target_os = "openbsd", target_os = "netbsd",
100-
target_os = "redox"))]
100+
target_os = "redox", target_os = "fuchsia"))]
101101
mod os {
102102
/// Check if the OS supports atomic close-on-exec for sockets
103103
pub fn socket_atomic_cloexec() -> bool {

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod net;
5757
#[deny(missing_docs)]
5858
pub mod poll;
5959
#[deny(missing_docs)]
60-
#[cfg(not(target_os = "redox"))]
60+
#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))]
6161
pub mod pty;
6262
pub mod sched;
6363
pub mod sys;

0 commit comments

Comments
 (0)