summary refs log tree commit diff
path: root/src/liblibc
AgeCommit message (Collapse)AuthorLines
2015-07-31fixes unused import compile failureDave Huseby-2/+2
2015-07-28Fixes #25155 and fixes #27359 by fixing the stat defines for both freebsd ↵Dave Huseby-4/+3
10.1 x86_64 and i686
2015-07-20Register new snapshotsAlex Crichton-4/+0
These new snapshots contain the knowledge of how to build the new triples of 32-bit MSVC and 32-bit FreeBSD, both of which should soon start having nightlies/auto builders! This does not currently register bitrig/freebsd snapshots but I believe those will be retroactively added in the near future.
2015-07-11adding support for i686-unknown-freebsd targetDave Huseby-0/+94
2015-07-10Show file name and access mode in Debug instance for File on OS XFlorian Hartwig-0/+5
2015-07-09Add FileTypeUnix trait to add unix special file typesJesús Espino-0/+6
2015-07-08trans: Link rlibs to dylibs with --whole-archiveAlex Crichton-0/+1
This commit starts passing the `--whole-archive` flag (`-force_load` on OSX) to the linker when linking rlibs into dylibs. The primary purpose of this commit is to ensure that the linker doesn't strip out objects from an archive when creating a dynamic library. Information on how this can go wrong can be found in issues #14344 and #25185. The unfortunate part about passing this flag to the linker is that we have to preprocess the rlib to remove the metadata and compressed bytecode found within. This means that creating a dylib will now take longer to link as we've got to copy around the input rlibs to a temporary location, modify them, and then invoke the linker. This isn't done for executables, however, so the "hello world" compile time is not affected. This fix was instigated because of the previous commit where rlibs may not contain multiple object files instead of one due to codegen units being greater than one. That change prevented the main distribution from being compiled with more than one codegen-unit and this commit fixes that. Closes #14344 Closes #25185
2015-07-06Rollup merge of #26809 - cmr:libc-ioctl, r=alexcrichtonSteve Klabnik-3/+3
None
2015-07-05liblibc: correct Linux ioctl request typeCorey Richardson-3/+3
2015-07-01Add netbsd amd64 supportAlex Newman-10/+18
2015-06-24Add flock() to liblibcAndy Grover-0/+27
2015-06-24Auto merge of #26521 - oli-obk:android-x86-libclibc, r=alexcrichtonbors-8/+13
All types are same as Android/arm. So I add condition for Android/x86 closes #25475 r? @alexcrichton
2015-06-23Support Android/x86 for liblibcMakoto Kato-8/+13
All types are same as Android/arm. So I add condition for Android/x86
2015-06-19liblibc: Fix prototype of functions taking `char *const argv[]`Geoffrey Thomas-16/+18
The execv family of functions do not modify their arguments, so they do not need mutable pointers. The C prototypes take a constant array of mutable C-strings, but that's a legacy quirk from before C had const (since C string literals have type `char *`). The Rust prototypes had `*mut` in the wrong place, anyway: to match the C prototypes, it should have been `*const *mut c_char`. But it is safe to pass constant strings (like string literals) to these functions. getopt is a special case, since GNU getopt modifies its arguments despite the `const` claim in the prototype. It is apparently only well-defined to call getopt on the actual argc and argv parameters passed to main, anyway. Change it to take `*mut *mut c_char` for an attempt at safety, but probably nobody should be using it from Rust, since there's no great way to get at the parameters as passed to main. Also fix the one caller of execvp in libstd, which now no longer needs an unsafe cast. Fixes #16290.
2015-06-15When building libc crate with musl, don't look for libc.aAidan Hobson Sayers-1/+4
musl may not be available on the target user's machine, and even if it is, we may not be able to find it because of how static libraries are searched for. Instead, use the transitively included liblibc which includes libc.a.
2015-06-04crate libc: Correct signature of `WriteFile`York Xiang-2/+2
2015-05-29Fix windows recvfrom definitionSteven Fackler-2/+1
2015-05-20Auto merge of #25350 - alexcrichton:msvc, r=brsonbors-0/+6
Special thanks to @retep998 for the [excellent writeup](https://github.com/rust-lang/rfcs/issues/1061) of tasks to be done and @ricky26 for initially blazing the trail here! # MSVC Support This goal of this series of commits is to add MSVC support to the Rust compiler and build system, allowing it more easily interoperate with Visual Studio installations and native libraries compiled outside of MinGW. The tl;dr; of this change is that there is a new target of the compiler, `x86_64-pc-windows-msvc`, which will not interact with the MinGW toolchain at all and will instead use `link.exe` to assemble output artifacts. ## Why try to use MSVC? With today's Rust distribution, when you install a compiler on Windows you also install `gcc.exe` and a number of supporting libraries by default (this can be opted out of). This allows installations to remain independent of MinGW installations, but it still generally requires native code to be linked with MinGW instead of MSVC. Some more background can also be found in #1768 about the incompatibilities between MinGW and MSVC. Overall the current installation strategy is quite nice so long as you don't interact with native code, but once you do the usage of a MinGW-based `gcc.exe` starts to get quite painful. Relying on a nonstandard Windows toolchain has also been a long-standing "code smell" of Rust and has been slated for remedy for quite some time now. Using a standard toolchain is a great motivational factor for improving the interoperability of Rust code with the native system. ## What does it mean to use MSVC? "Using MSVC" can be a bit of a nebulous concept, but this PR defines it as: * The build system for Rust will build as much code as possible with the MSVC compiler, `cl.exe`. * The build system will use native MSVC tools for managing archives. * The compiler will link all output with `link.exe` instead of `gcc.exe`. None of these are currently implemented today, but all are required for the compiler to fluently interoperate with MSVC. ## How does this all work? At the highest level, this PR adds a new target triple to the Rust compiler: x86_64-pc-windows-msvc All logic for using MSVC or not is scoped within this triple and code can conditionally build for MSVC or MinGW via: #[cfg(target_env = "msvc")] It is expected that auto builders will be set up for MSVC-based compiles in addition to the existing MinGW-based compiles, and we will likely soon start shipping MSVC nightlies where `x86_64-pc-windows-msvc` is the host target triple of the compiler. # Summary of changes Here I'll explain at a high level what many of the changes made were targeted at, but many more details can be found in the commits themselves. Many thanks to @retep998 for the excellent writeup in rust-lang/rfcs#1061 and @rick26 for a lot of the initial proof-of-concept work! ## Build system changes As is probably expected, a large chunk of this PR is changes to Rust's build system to build with MSVC. At a high level **it is an explicit non goal** to enable building outside of a MinGW shell, instead all Makefile infrastructure we have today is retrofitted with support to use MSVC instead of the standard MSVC toolchain. Some of the high-level changes are: * The configure script now detects when MSVC is being targeted and adds a number of additional requirements about the build environment: * The `--msvc-root` option must be specified or `cl.exe` must be in PATH to discover where MSVC is installed. The compiler in use is also required to target x86_64. * Once the MSVC root is known, the INCLUDE/LIB environment variables are scraped so they can be reexported by the build system. * CMake is required to build LLVM with MSVC (and LLVM is also configured with CMake instead of the normal configure script). * jemalloc is currently unconditionally disabled for MSVC targets as jemalloc isn't a hard requirement and I don't know how to build it with MSVC. * Invocations of a C and/or C++ compiler are now abstracted behind macros to appropriately call the underlying compiler with the correct format of arguments, for example there is now a macro for "assemble an archive from objects" instead of hard-coded invocations of `$(AR) crus liboutput.a ...` * The output filenames for standard libraries such as morestack/compiler-rt are now "more correct" on windows as they are shipped as `foo.lib` instead of `libfoo.a`. * Rust targets can now depend on native tools provided by LLVM, and as you'll see in the commits the entire MSVC target depends on `llvm-ar.exe`. * Support for custom arbitrary makefile dependencies of Rust targets has been added. The MSVC target for `rustc_llvm` currently requires a custom `.DEF` file to be passed to the linker to get further linkages to complete. ## Compiler changes The modifications made to the compiler have so far largely been minor tweaks here and there, mostly just adding a layer of abstraction over whether MSVC or a GNU-like linker is being used. At a high-level these changes are: * The section name for metadata storage in dynamic libraries is called `.rustc` for MSVC-based platorms as section names cannot contain more than 8 characters. * The implementation of `rustc_back::Archive` was refactored, but the functionality has remained the same. * Targets can now specify the default `ar` utility to use, and for MSVC this defaults to `llvm-ar.exe` * The building of the linker command in `rustc_trans::back::link` has been abstracted behind a trait for the same code path to be used between GNU and MSVC linkers. ## Standard library changes Only a few small changes were required to the stadnard library itself, and only for minor differences between the C runtime of msvcrt.dll and MinGW's libc.a * Some function names for floating point functions have leading underscores, and some are not present at all. * Linkage to the `advapi32` library for crypto-related functions is now explicit. * Some small bits of C code here and there were fixed for compatibility with MSVC's cl.exe compiler. # Future Work This commit is not yet a 100% complete port to using MSVC as there are still some key components missing as well as some unimplemented optimizations. This PR is already getting large enough that I wanted to draw the line here, but here's a list of what is not implemented in this PR, on purpose: ## Unwinding The revision of our LLVM submodule [does not seem to implement][llvm] does not support lowering SEH exception handling on the Windows MSVC targets, so unwinding support is not currently implemented for the standard library (it's lowered to an abort). [llvm]: https://github.com/rust-lang/llvm/blob/rust-llvm-2015-02-19/lib/CodeGen/Passes.cpp#L454-L461 It looks like, however, that upstream LLVM has quite a bit more support for SEH unwinding and landing pads than the current revision we have, so adding support will likely just involve updating LLVM and then adding some shims of our own here and there. ## dllimport and dllexport An interesting part of Windows which MSVC forces our hand on (and apparently MinGW didn't) is the usage of `dllimport` and `dllexport` attributes in LLVM IR as well as native dependencies (in C these correspond to `__declspec(dllimport)`). Whenever a dynamic library is built by MSVC it must have its public interface specified by functions tagged with `dllexport` or otherwise they're not available to be linked against. This poses a few problems for the compiler, some of which are somewhat fundamental, but this commit alters the compiler to attach the `dllexport` attribute to all LLVM functions that are reachable (e.g. they're already tagged with external linkage). This is suboptimal for a few reasons: * If an object file will never be included in a dynamic library, there's no need to attach the dllexport attribute. Most object files in Rust are not destined to become part of a dll as binaries are statically linked by default. * If the compiler is emitting both an rlib and a dylib, the same source object file is currently used but with MSVC this may be less feasible. The compiler may be able to get around this, but it may involve some invasive changes to deal with this. The flipside of this situation is that whenever you link to a dll and you import a function from it, the import should be tagged with `dllimport`. At this time, however, the compiler does not emit `dllimport` for any declarations other than constants (where it is required), which is again suboptimal for even more reasons! * Calling a function imported from another dll without using `dllimport` causes the linker/compiler to have extra overhead (one `jmp` instruction on x86) when calling the function. * The same object file may be used in different circumstances, so a function may be imported from a dll if the object is linked into a dll, but it may be just linked against if linked into an rlib. * The compiler has no knowledge about whether native functions should be tagged dllimport or not. For now the compiler takes the perf hit (I do not have any numbers to this effect) by marking very little as `dllimport` and praying the linker will take care of everything. Fixing this problem will likely require adding a few attributes to Rust itself (feature gated at the start) and then strongly recommending static linkage on Windows! This may also involve shipping a statically linked compiler on Windows instead of a dynamically linked compiler, but these sorts of changes are pretty invasive and aren't part of this PR. ## CI integration Thankfully we don't need to set up a new snapshot bot for the changes made here as our snapshots are freestanding already, we should be able to use the same snapshot to bootstrap both MinGW and MSVC compilers (once a new snapshot is made from these changes). I plan on setting up a new suite of auto bots which are testing MSVC configurations for now as well, for now they'll just be bootstrapping and not running tests, but once unwinding is implemented they'll start running all tests as well and we'll eventually start gating on them as well. --- I'd love as many eyes on this as we've got as this was one of my first interactions with MSVC and Visual Studio, so there may be glaring holes that I'm missing here and there! cc @retep998, @ricky26, @vadimcn, @klutzy r? @brson
2015-05-19libc: Add necessary libraries for MSVCAlex Crichton-0/+6
These libs seem to be required by the standard library at least to link successfully!
2015-05-15libs: Move favicon URLs to HTTPSAlex Crichton-1/+1
Helps prevent mixed content warnings if accessing docs over HTTPS. Closes #25459
2015-05-12Add wait and waitpid to libc.Mike Sampson-0/+6
2015-05-09Rollup merge of #25211 - huonw:libc, r=cmrManish Goregaokar-1/+2
Many many many people ask in #rust about this libraries, having an explanatory reason will probably help a lot.
2015-05-09Rollup merge of #25140 - kevinmehall:mips, r=steveklabnikManish Goregaokar-0/+24
Building with `--target=mipsel-unknown-linux-gnu` currently results in the following errors, fixed by this PR: ``` rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/mipsel-unknown-linux-gnu/lib/libstd /vol/rust/src/libstd/os/linux/raw.rs:76:21: 76:28 error: use of undeclared type name `c_ulong` /vol/rust/src/libstd/os/linux/raw.rs:76 pub st_dev: c_ulong, ^~~~~~~ /vol/rust/src/libstd/os/linux/raw.rs:83:22: 83:29 error: use of undeclared type name `c_ulong` /vol/rust/src/libstd/os/linux/raw.rs:83 pub st_rdev: c_ulong, ^~~~~~~ /vol/rust/src/libstd/sys/common/net2.rs:210:52: 210:70 error: unresolved name `libc::TCP_KEEPIDLE` /vol/rust/src/libstd/sys/common/net2.rs:210 setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, ```
2015-05-08Add a reason to the libc & rand instability.Huon Wilson-1/+2
Many many many people ask in #rust about this libraries, having an explanatory reason will probably help a lot.
2015-05-06Move the SC constants for macos to an accessible module (fixes #24374 for mac).Ms2ger-133/+44
These constants were added in 6f54ce9aa5d2baf0cd82c01e2c181ab17439b7d7 and e8fbd1ce048fdfc2db1d446fedfe8775ce446046 to a consts module that is behind a gate. I have not confirmed that these constants do indeed work on either OSX or iOS. It appears that some of the constants may actually belong in a POSIX module, but I didn't make these changes here because I don't have access to the POSIX standard.
2015-05-05Add TCP_* constants for mips/mipsel LinuxKevin Mehall-0/+24
PR #24611 added these for other architectures, but missed the `#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]` version of the module. The values are the same.
2015-04-27std: Prepare for linking to muslAlex Crichton-1/+5
This commit modifies the standard library and its dependencies to link correctly when built against MUSL. This primarily ensures that the right libraries are linked against and when they're linked against they're linked against statically.
2015-04-21add TCP_* consts for linuxYoung Wu-0/+24
2015-04-21Implement Debug for FileChris Wong-0/+2
This patch adds a `Debug` impl for `std::fs::File`. On all platforms (Unix and Windows) it shows the file descriptor. On Linux, it displays the path and access mode as well. Ideally we should show the path/mode for all platforms, not just Linux, but this will do for now. cc #24570
2015-04-18Auto merge of #24464 - lambdaburrito:master, r=alexcrichtonbors-0/+127
resolves #24462
2015-04-16Auto merge of #24306 - l0kod:libc-noctty, r=alexcrichtonbors-0/+5
cf. open(2): If the open file refers to a terminal device it will not become the process's controlling terminal even if the process does not have one.
2015-04-15fix tabspez-93/+93
2015-04-15add all SC constants for macosJames Perry-1/+128
2015-04-13remove duplicated linux sysconf modpez-6/+2
2015-04-13added _SC_NPROCESSORS_ONLN constants for linux and macos for fix #24374pez-0/+15
2015-04-11libc: Add O_NOCTTYMickaël Salaün-0/+5
2015-04-02unary negation of unsigned integersSébastien Marie-3/+3
unbreak build for: - linux (mips/mipsel) - freebsd - dragonfly - bitrig - openbsd by converting unsigned integers `-1` to `!0`
2015-04-02don't derive Clone, but impl itSébastien Marie-6/+24
affected struct: - sockaddr_storage - sockaddr_un apply the same method used for linux for: - bitrig/openbsd - freebsd - dragonfly
2015-04-02Tweak relese notes + rebase fixesAlex Crichton-11/+34
2015-04-01Test fixes and rebase conflicts, round 2Alex Crichton-3/+3
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-141/+148
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-02Test fixes and rebase conflicts, round 2Alex Crichton-1/+1
Conflicts: src/libcore/num/mod.rs
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-1/+1
2015-04-01Fix enum timezone across all platforms.Niko Matsakis-5/+5
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-141/+148
2015-03-28libc: Don't use unstable apisAlex Crichton-1/+4
Right now the `std::isize::BYTES` typedef is `#[unstable]`, but liblibc is using this, preventing it from compiling on stable Rust.
2015-03-26Register new snapshotsAlex Crichton-1/+1
2015-03-24Test fixes and rebase conflicts, round 2Alex Crichton-0/+1
2015-03-24rollup merge of #23659: GBGamer/masterAlex Crichton-0/+48
For other permissions beside USR permissions, we need these constants. fixes #23658
2015-03-24Add the other S_I(RWX)(GRP/OTH) for posix `creat`Nicholas Mazzuca-0/+48