gcc & glibc & ABI compatibility?

This questions are for Mr. Roman Shaposhnik,

What problems should I expect to encounter in the current preview release of Sun Studio for linux with respect to gcc & glibc & ABI compatibility?

What are the recommended equivalent CFLAGS to something like "-O2 -march=i686 -pipe -fomit-frame-pointer" for Sun Studio in linux?

May I assume that the code compiled with Sun Studio in linux is less suceptible to buffer overflow attacks, i.e. is it like having smash stack protection in gcc?

Is it possible to bootstrap gcc or compile glibc with Sun Studio for Linux or is it pointless?

Any guidance is greatly appreciated. I've had various degrees of succes compiling stuff in Solaris 10 x86 with Studio 10 and 11 but the case is this:

I run some developement machines on Solaris 10 x86 06/06 with Sun Studio 11 and I had issues trying to compile programs designed to use gcc + glibc + nasm. Usually, multimedia libraries and multimedia programs give the most headaches ;) (xine-lib or equ-xmms both use very aggressive optimizations at compile time, like cpu autodetect features or SIMD instructions and I couldn't figure out how to make them work with Studio 11).

In my tests I've found that Sun Studio is an awesome compiler and a better compiler than gcc in Solaris, but due to the way gnu software is written it is usually hard to get it to compile right in one try without hacking some makefile or adding lots of include paths.

Thank you guys for making this release available and I look forward to some enlightening here!!!

[1596 byte] By [tommynux] at [2007-11-26 9:42:38]
# 1
I will leave most of your questions for Roman, but if you post the specific gcc options or macros that are used we could suggest what the correspondingoption is in Sun Studio compilers.--chris
ChrisQuenelle at 2007-7-7 0:42:25 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

I don't have a specific macro in mind, but maybe this clarifies some of my issues:

I mantain a build of Ipcop linux firewall tuned to my specific system administration and security needs. The build scripts are derived form LFS (Linux from scratch), and they pass to the build system compile time options, i.e. "-O2 -march=$arch ... etc." plus some packages have their own independant CFLAGS which are not set by the main config file. So, my current goal here is to experiment with Sun Studio for Linux to build better code which is less vulnerable to attacks due to the fact that I used Sun Studio instead of gcc 3.x.x.

I want to find out if this is actually possible or if should move my "Do It Yourself" firewall appliances to another Operating Environment (i.e. a slimmed SunOS). If you ever compile free or gnu software in Solaris with Sun Studio you'll find it "feels" faster and probably is less vulnerable to certain types of attacks.

I think that someone like Roman may clarify the issue for good and save me & my team a lot of time and frustration. I'm not sure if compiling a Linux toolchain from scratch is a feasible option with sun studio. I would love some apps, for instance the full LAMP stack plus squid and snort to compile cleanly in Sun Studio 11 for Linux. That would be my little piece of heaven. :D

In his SDN interview, Roman explained how he profiled/optimized ffmpeg's code using sunstudio on sparc and that the benefits were seen on all of the architectures that the code supported. This example is the kind of accomplishment I want to achieve and the fact that we have sunstudio for linux could mean we may see a "better" linux in the near future.

Message was edited by:

tommynux

tommynux at 2007-7-7 0:42:25 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

Hi Tommynux!

First to answer some of your original questions:

> What problems should I expect to encounter in the current

> preview release of Sun Studio for linux with respect to

> gcc & glibc & ABI compatibility?

The short answer is that with each Sun Studio Express build

we put out there (Sun Studio Express is the new program which

replaced Compilers On Linux Technology Preview) you

should expect more and more compatibility and by the

time this product gets released we hope to achieve

100% compatibility on the C side and do our best for C++.

A somewhat longer answer would be:

1. As far as glibc is concerned we should be compatible already

if you notice we are not -- file a bug or post to this forum.

2. As far as gcc (as in C compiler) compatibility goes we currently

are ABI compatible, but we're still working on full implementation

of the following gcc source level features:

2.1. __asm__ extensions

2.2. __attribute__ extensions

If you have lots of those in your code -- it probably won't work. That

said, however, we would appreciate if you tell us exactly what

doesn't work so that we can implement those particular extensions

first.

3. As far as G++ compatibility goes we've got quite a lot of work ahead

of us. Currently we are *NOT* G++ ABI compatible and we implement

our own C++ ABI on Linux (compatible with Solaris one). Which means

that if you have some 3rd party C++ libraries and you don't have an

option of recompiling them with Sun Studio C++ compiler -- you're

in trouble.

> What are the recommended equivalent CFLAGS to something

> like "-O2 -march=i686 -pipe -fomit-frame-pointer" for Sun Studio in linux?

I have one slide that I like to call "30 seconds optimization school". Basically

with Sun Studio it as always a good idea to start with:

-fast -xipo=2 -xarch=<target cpu>

Once you build your project that way -- use Performance Analyzer to

see what's going on and start experimenting with different options.

We've got a nice introduction into this magic available at the

following URL: http://developers.sun.com/prodtech/cc/articles/amdopt.html

Also I'm about to publish my slides here:

http://blogs.sun.com/rvs

once I'm done fixing the mess they've created

there by upgrading blogging software. :-(

> May I assume that the code compiled with Sun Studio in linux is less

> suceptible to buffer overflow attacks, i.e. is it like having smash stack

> protection in gcc?

Not really.

> Is it possible to bootstrap gcc or compile glibc with Sun Studio for

> Linux or is it pointless?

gcc by default bootstraps itself anyway, so it doesn't matter what you use

to compile boot0 phase. glibc, at least theoretically, can benefit from

Sun Studio. It'll be very nice if you can try that and post the results to

this forum.

> I mantain a build of Ipcop linux firewall tuned to my

> specific system administration and security needs.

> The build scripts are derived form LFS (Linux from

> scratch), and they pass to the build system compile

> time options, i.e. "-O2 -march=$arch ... etc." plus

> some packages have their own independant CFLAGS which

> are not set by the main config file. So, my current

> goal here is to experiment with Sun Studio for Linux

> to build better code which is less vulnerable to

> attacks due to the fact that I used Sun Studio

> instead of gcc 3.x.x.

As I keep pointing out -- if you're really serious about

performance of your application you should make performance

testign part of your routine as much as everybody has

regression testing as part of their routine. Start with

the flags outline in the quoted article and keep poking

around with Performance Analyzer -- that's exactly what

I did for ffmpeg.

I would be more than happy to assist you, but you

have to help me first by coming up with the meaningful

set of performance related workloads of your app.

> I think that someone like Roman may clarify the issue

> for good and save me & my team a lot of time and

> frustration.

I'd be very happy to do that for you.

> I would love some apps, for instance the full

> LAMP stack plus squid and snort to compile cleanly in

> Sun Studio 11 for Linux. That would be my little

> piece of heaven. :D

Now that is an interesting proposition. I'm pretty

sure that LAMP should be totally compatible with

Sun Studio on Linux even now. Tuning it for

performance might be an interestign excersize

as well. It actually looks like a very nice subject

for a whitepaper treatment. Say, would you be

interested in [co-]authoring such a whitepaper

with a chance of getting a due recognition ? ;-)

http://developers.sun.com/prodtech/cc/heroes.html

> In his SDN interview, Roman explained how he

> profiled/optimized ffmpeg's code using sunstudio on

> sparc and that the benefits were seen on all of the

> architectures that the code supported. This example

> is the kind of accomplishment I want to achieve and

> the fact that we have sunstudio for linux could mean

> we may see a "better" linux in the near future.

That's exactly our hope as well.

Thanks,

Roman.

romans at 2007-7-7 0:42:25 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

Hi Roman!!!

First, thank you for your detailed reply & for clarifying the comptability status of SunCC. Your explanation alone worths the task of moving my development environment to SunCC for further investigastion.

> Now that is an interesting proposition. I'm

> pretty

> ure that LAMP should be totally compatible with

> Sun Studio on Linux even now. Tuning it for

> performance might be an interestign excersize

> as well. It actually looks like a very nice subject

> for a whitepaper treatment. Say, would you be

> interested in [co-]authoring such a whitepaper

> with a chance of getting a due recognition ? ;-)

>

> ttp://developers.sun.com/prodtech/cc/heroes.html

Second, I'm am very flattered by your proposal. I'm starting my tests right now and I hope to be in touch with you soon for further discussion of this subject. I hope to be able to post some preliminary feedback and results soon. :D

> Also I'm about to publish my slides here:

>http://blogs.sun.com/rvs

> I'm done fixing the mess they've created

> here by upgrading blogging software. :-(

I'll check this out. The more info we can get, the better for everyone using SunCC on Linux. Also, keep posting those flash demos on your blog, they are great and hearing from an actual developer who uses the product is way better than a voiceover of some actor.

>http://developers.sun.com/prodtech/cc/articles/amdopt.html

How did I manage to miss this out? ;)

Lastly, thank you for sharing your experience with us. I think we have very exiting times ahead of us with the availability of SunCC for Linux. Having Sun Studio for our platform raises the bar and the credibility of the platform to a higher level.

Tomas Gayoso

tommynux at 2007-7-7 0:42:25 > top of Java-index,Development Tools,Solaris and Linux Development Tools...