Boost Fiber on OS X - macos

I'm trying to get boost fiber up and running on os x, and I'm having quite a few issues. First, fiber won't compile with Apple clang because of the use of thread_local which Apple does not support (according to what I found online, they think they can implement it better than standard llvm and don't want to introduce it only to break ABI later).
So instead, I tried using gcc-5 installed through homebrew. After a bit of screwing around with boost build I managed to get fiber to build, and I can link sample programs successfully, but they seg fault.
Then I figured I'd give current llvm a try, since it has thread_local support, and I can again get boost fiber to build fine, but now I'm getting issues because the os x linker doesn't seem to handle thread local properly either! I would post the exact error, but my power is out. I did actually get it to link though with a couple changes to fiber, but the sample program failed again.
So the question is, how can I make this happen? Is there any way to get another linker working to produce os x executables for me? Llvm comes with another linker called lld, but I don't think it does what I'm after.
I think if I absolutely had to, I could go through fiber and boost context replacing all thread_local with boost::thread_specific_ptr, but I'm not sure how deep that rabbit hole goes. Any suggestions?

Related

Trying to find out what specific atom package changed terminal functionality

I installed Atom over the weekend and installed some packages to make it more functional. After installing some of the packages, I ran terminal and ran a g++ command to compile some software and the error codes and display now look a lot different. Its actually much more clear in this form what the issues are, but that's besides the point. I'm wondering if anyone might know which package might've caused this sort of change? The easiest thing to do would be be to list all of the packages I downloaded, but I downloaded quite a few and ended up uninstalling some, so I don't even have a definitive list of what they could be. I'm not even 100 percent positive that it was an Atom package that changed the g++ output, but I don't recall it looking this way before. What I'm referring to is the error message and the green arrow pointing to the exact issue. I don't believe this was the way the output looked before after trying to compile a program with issues.
I realize this is a vague request to track down, but if anyone has any idea which package might've changed the way g++ outputs errors to the screen, that would be awesome.
I'm ultimately trying to figure out how to remove whatever it was that changed it and go back to the original output, so if anyone has any suggests for maybe reverting the functionality, I would try that as well.
Apparently, I've spent a majority of my time compiling in the linux shell via g++ that I never really paid attention to the the way the error messages look in mac terminal when using g++.
After a bit of digging, I found that g++ is using clang. After looking at the clang documentation for "Expressive Diagnostics," I've come to find that these sort of markups (what Clang devs are calling "Caret Diagnostics and Range Highlighting") are normal and standard, not installed by Atom. I must've drawn that conclusion randomly out of paranoia, after installing packages and packages for Atom and only then, noticing the difference in error output between Linux shell g++ and Mac Terminal g++.
A poster named "Adam" suggests that "Homebrew" is an easier way of getting Terminal to revert back to using GCC instead of Clang, which should be close to what I'm used to with the Linux shell experience with g++

Clang Mac OS X Maveric, not supporting fsanitize=undefined

I'm getting a segfault in my C program, and I thought I'd use Clangs help in figuring out why, as Valgrind isn't supported (yet).
I try to compile my program with -fsanitize=undefined to activiate runtime checks for undefined behaviour. All I'm getting is an error message which reads something like: "fsanitize doesn't support option 'undefined'". I've also tried using -fsanitize=address with the same result :/
Anyone know why this is?
It seems like -fsanitize is not supported by apple's CLang.
If you go here http://llvm.org/releases/download.html#3.4 you can get the prebuild binaries of clang, that do recognize this option.
However this is harder because then you have to use a Makefile,
IF by chance you use cmake, then you can just easily go to use makefiles.
OR replace the binaries in the Xcode.app/Contents/Developer/Toolchains/.../bin
but I don't know what can happen if you replace Apples binaries, do a backup before to be able to restore.
Honestly, I'm not myself confortable about replacing apple's binaries, because they probably added something in the clang to make it work with Xcode nicely.
Again, the GPL policy of GCC had this advantage that apple could not modify it.
-> another solution is to develop on linux,
The port to windows of CLang is on its way, but not ready yet, maybe in 3.5.
Best

Compiling on Lion --clang

Can someone either explain or preferably point me toward some documentation that explains the difference between passing --clang and not passing it to the gcc compiler.
I've had to append this parameter on numerous packages when compiling and I don't know what it does, I have yet to personally encounter code that won't compile without it but other projects seem to require it. I can not find it in the man docs for gcc, so I am trying to find a little bit more about what it is, all I know is that it has to do with the LLVM.
There's no --clang option to anything. clang is another compiler for OS X and is available inside Xcode as "clang". It's another compiler similar to gcc, and is the new default compiler for OS X.
A link from the Apple Developer Website explains more.

Windows based development for ARM processors

I am a complete newbie to the ARM world. I need to be able to write C code, compile it, and then download into an ARM emulator, and execute. I need to use the GCC 4.1.2 compiler for the C code compilation.
Can anybody point me in the correct directions for the following issues?
What tool chain to use?
What emulator to use?
Are there tutorials or guides on setting up the tool chain?
building a gcc cross compiler yourself is pretty easy. the gcc library and the C library and other things not so much, an embedded library and such a little harder. Depends on how embedded you want to get. I have little use for gcclib or a c library so roll your own works great for me.
After many years of doing this, perhaps it is an age thing, I now just go get the code sourcery tools. the lite version works great. yagarto, devkitarm, winarm or something like that (the site with a zillion examples) all work fine. emdebian also has a good pre-built toolchain. a number of these places if not all have info on how they built their toolchains from gnu sources.
You asked about gcc, but bear in mind that llvm is a strong competitor, and as far as cross compiling goes, since it always cross compiles, it is a far easier cross compiler to download and build and get working than gcc. the recent version is now producing code (for arm) that competes with gcc for performance. gcc is in no way a leader in performance, other compilers I have used run circles around it, but it has been improving with each release (well the 3.x versions sometimes produce better code than the 4.x versions, but you need 4.x for the newer cores and thumb2). even if you go with gcc, try the stable release of llvm from time to time.
qemu is a good emulator, depending on what you are doing the gba emulator virtual gameboy advance is good. There are a couple of nds emulators too. GDB and other places have what appear to be ARMs own armulator. I found it hard to extract and use, so I wrote my own, but being lazy only implemented the thumb instruction set, I called mine the thumbulator. easy to use. Far easier than qemu and armulator to add peripherals to and watch and debug your code. ymmv.
Hmmm I posted a similar answer for someone recently. Google: arm verilog and at umich you will find a file isc.tgz in which is an arm10 behavioural (as in you cannot make a chip from it therefore you can find verilog on the net) model. Which for someone wanting to learn an instruction set, watching your code execute at the gate level is about as good as it gets. Be careful, like a drug, you can get addicted then have a hard time when you go back to silicon where you have relatively zero visibility into your code while it is executing. Somewhere in stackoverflow I posted the steps involved to get that arm10 model and another file or two to turn it into an arm emulator using icarus verilog. gtkwave is a good and free tool for examining the wave (vcd) files.
Above all else you will need the ARM ARM. (The ARM Architectural Reference Manual). Just google it and find it on ARM's web site. There is pseudo code for each instruction teaching you what they do. Use the thumbulator or armulator or others if you need to understand more (mame has an arm core in it too). I make no guarantees that the thumbulator is 100% debugged or accurate, I took some common programs and compared their output to silicon both arm and non-arm to debug the core.
Toolchain you can use Yagarto http://www.yagarto.de/
Emulator you can use Proteus ISIS http://www.labcenter.com/index.cfm
(There is a demo version)
and tutorials, well, google them =)
Good luck!

How can I compile object code for the wrong system and cross compiling question?

Reference this question about compiling. I don't understand how my program for Mac can use the right -arch, compile with those -arch flags, the -arch flags be for the system I am on (a ppc64 g5), and still produce the wrong object code.
Also, if I used a cross compiler and was on Linux, produced 10.5 code for mac, how would this be any different than what I described above?
Background is that I have tried to compile various apache modules. They compile with the -arch ppc, ppc64, etc. I get no errors and I get my mod_whatever.so. But, apache will always complain that some symbol isn't found. Apparently, it has to do with what the compiler produces, even though the file type says it is for ppc, ppc64, i386, x_64 (universal binary) and seems to match all the other .so mods I have.
I guess I don't understand how it could compile for my system with no problem and then say my system can't use it. Maybe I do not understand what a compiler is actually giving me.
EDIT: All error messages and the complete process can be seen here.
Thank you.
Looking at the other thread and elsewhere and without a G5 or OSX Server installation, I can only make a few comments and suggestions but perhaps they will help.
It's generally not a good idea to be modifying the o/s vendor's installed software. Installing a new Apache module is less problematic than, say, overwriting an existing library but you're still at the mercy of the vendor in that a Software Update could delete your modifications and, beyond that you have to figure out how the vendor's version was built in the first place. A common practice in the OS X world is to avoid this by making a completely separate installation of an open source product, like Apache, using, for instance, MacPorts. That has its cons, too: to achieve a high-level of independence, MacPorts will often download and build a lot of dependent packages for things which are already in OS X but there's no harm in that other than some extra build cycles and disk space.
That said, it should be possible to build and install apache modules to supplement those supplied by Apple. Apple does publish the changes it makes to open source products here; you can drill down in the various versions there to find the apache directory which contains the source, Makefile and applied patches. That might be of help.
Make sure that the mod_*.so you build are truly 64-bit and don't depend on any non-64 bit libraries. Use otool -L mod_*.so to see the dynamic libraries that each references and then use file on those libraries to ensure they all have ppc64 variants.
Make sure you are using up-to-date developer tools (Xcode 3.1.3 is current).
While the developer tool chain uses many open source components, Apple has enhanced many of them and there are big differences in OS X's ABIs, universal binary support, dynamic libraries, etc. The bottom line is that cross-compilation of OS X-targeted object code on Linux (or any other non-OS X platform) is neither supported nor practical.

Resources