Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rust CFLAGS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
paluszak
Apprentice
Apprentice


Joined: 28 Jun 2004
Posts: 265
Location: Warsaw, Poland

PostPosted: Wed Feb 13, 2019 2:12 pm    Post subject: rust CFLAGS Reply with quote

Hi,

Is there a way to add CPU-specific flags for rust ebuilds to make.conf? For instance something along the lines '-C target-cpu=native' to generate CPU optimized code? Or possibly other codegen options (https://doc.rust-lang.org/rustc/codegen-options/index.html)?

J.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Wed Feb 13, 2019 7:31 pm    Post subject: Reply with quote

paluszak,

Yes and no.

Yes you can have per package CFLAGS. No, you don't do it in make.conf.

The process is documented in Per-package environment variables
The worked example is for debugging but you will be able to adapt it.

-- edit --

EXTRA_ECONF= lets you pass additional options to some build systems.
This may be useful too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
paluszak
Apprentice
Apprentice


Joined: 28 Jun 2004
Posts: 265
Location: Warsaw, Poland

PostPosted: Wed Feb 13, 2019 7:41 pm    Post subject: Reply with quote

I know how to set up per-package CFLAGS, but what I'm asking about is if there's an equivalent of CFLAGS for rust packages. For istance, I'd like my rust packages to be built with '-C target-cpu=native' option added to command line.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Wed Feb 13, 2019 8:41 pm    Post subject: Reply with quote

paluszak,

Sorry, I misunderstood your question. I can delete my posts and your response to get your opening post back into the unanswered post search if you like.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
paluszak
Apprentice
Apprentice


Joined: 28 Jun 2004
Posts: 265
Location: Warsaw, Poland

PostPosted: Wed Feb 13, 2019 8:59 pm    Post subject: Reply with quote

No, that's fine. I'll try to delve into the rust eclass. For now I found only that setting RUSTFLAGS env value adds given options to cargo builds, but that's what I found in the cargo man page. So it's kind of solved, but only kind of - afaik you can use rustc directly and not exclusively via cargo build system.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Sat Mar 30, 2019 7:58 am    Post subject: Reply with quote

Putting RUSTFLAGS="-C target-cpu=native" into make.conf seems to have an effect - tested by putting an invalid option in there and watching emerge fail.

Unlike CFLAGS it's probably safe to use native there for the foreseeable future because rust has no distcc support.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Sat Mar 30, 2019 10:47 am    Post subject: Reply with quote

Ant P.

For a long time now using -march=native in CFLAGS has been 'safe' with distcc.
distcc won't distribute when it sees that.
You no longer gent a mix of arches back, depending on what built on what arch.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
paluszak
Apprentice
Apprentice


Joined: 28 Jun 2004
Posts: 265
Location: Warsaw, Poland

PostPosted: Sat Mar 30, 2019 10:51 am    Post subject: [SOLVED] rust CFLAGS Reply with quote

Ant P. wrote:
Putting RUSTFLAGS="-C target-cpu=native" into make.conf seems to have an effect - tested by putting an invalid option in there and watching emerge fail.

Unlike CFLAGS it's probably safe to use native there for the foreseeable future because rust has no distcc support.


Yep, I noticed that. Seems to work perfectly fine. There are some build that fail with lto, mostly those linking against external C code, like Firefox.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum