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 conditional compilation system to allow features available only on some platforms. #98

Closed
carllerche opened this issue Apr 9, 2015 · 7 comments

Comments

@carllerche
Copy link
Contributor

I removed a number of bindings that were not generally portable in order to get everything compiling on Rust 1.0 beta. These should be brought back.

@kamalmarhubi
Copy link
Member

Thinking about #264 (using definitions from libc), we may want our own analog of the sys module pattern. Right now it's hard to track down where items come in because the cfg attrs are all over the place. @arcnmx you have a recently opened RFC on a related topic. Thoughts?

@arcnmx
Copy link
Contributor

arcnmx commented Feb 21, 2016

Well, I'd say it's an unrelated issue in regards to my proposal toward libstd, which is more about defining an abstraction layer over the OS for libstd to use. libstd has a lot of ifdef/else/elif/etc going on where different implementations are used depending on the platform. nix seems more all-or-nothing; everything is in the right place, just cfg'd out if something doesn't apply to a given platform.

That said, moving all the mod ffi stuff into another layer under nix with the maybe-goal of eventually migrating it all into libc could potentially be a good idea. It would let us make it a public separate nix-sys crate too that only defines the raw C API.

it's hard to track down where items come in because the cfg attrs are all over the place

Not sure I understand what you mean by that, what's hard? Most items are cfg'd out directly at their definition point AFAIR

@kamalmarhubi
Copy link
Member

Ah I see. Maybe I actually meant a file layout more like libc's then. A way to have a hierarchy of related systems, so that there's a clear place to put definitions. Then we can use conditional module imports instead of conditional definitions. It seems like less mental effort to me in terms of where to put things.

@kamalmarhubi
Copy link
Member

Here's the section describing it in the libc RFC: https://github.com/alexcrichton/rfcs/blob/pomote-libc/text/0000-promote-libc.md#internal-structure

@fiveop
Copy link
Contributor

fiveop commented Feb 27, 2016

Currently, I am against this change. libc has this structure and it fits with its concept. For us, I do not see the advantage, but am rather afraid it would lead to a lot of code duplication. This is the case in libc, and I do not see a way around that there. However, we can use that libc hides that fact, by using their constants and function declarations. This would leave us with configuring a few functions and certain constants in bitflags and enums in and out depending on platform.

@kamalmarhubi
Copy link
Member

This makes sense. We should get fully onto libc definitions (#264) first, then see what it looks like.

@Susurrus
Copy link
Contributor

Susurrus commented Jun 5, 2017

I think the current consensus is to defer on this. Should I close this issue and it can be revisited if necessary?

bors bot added a commit that referenced this issue Jul 18, 2017
681: Remove feature flags r=Susurrus

These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the `execvpe` has been broken for forever.

The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The `execvpe` function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).

Closes #98.
Closes #206.
Closes #306.
Closes #308.
bors bot added a commit that referenced this issue Jul 19, 2017
681: Remove feature flags r=Susurrus

These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the `execvpe` has been broken for forever.

The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The `execvpe` function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).

Closes #98.
Closes #206.
Closes #306.
Closes #308.
@bors bors bot closed this as completed in #681 Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants