cross compiling

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: cross compiling

Post by Don »

wgarvin wrote:
Don wrote:My problems is not so much with the OS but with Microsoft. ... The problem with Microsoft is the same as most big corporations - they are basically criminal. Corporations have rights like people (the supreme court basically recognizes them as "people" in the late 1800's) but most would be judged as psychopaths if they were evaluated by psychologists.
Yeah. Anyone paying attention to Microsoft's actions for the past 25 years can probably think of numerous examples of evil stuff they have done, that has harmed the progress of the software industry or put specific competitors out of business.

Embrace, Extend and Extinguish is the name they used internally for their strategy, which they continue to apply to this day, of initially adopting some competitor's open standard or platform, and then perverting it with proprietary extensions until they can eventually squeeze that competitor out of the market. I don't have a list handy of all of the companies and products that Microsoft has marginalized or outright extinguished over the years, but its not exactly a short list. Some examples I can think of off the top of my head are Netscape Navigator, Java (the rare survivor), WordPerfect, Stacker (which MS ripped off to create DoubleSpace).

In the 90's, the U.S. goverment prosecuted a case against Microsoft for violation of anti-trust laws (abusing their OS monopoly to their own advantage in other markets), but the punishment ended up being a slap on the wrist. More recently, the European Commission also found MS guilty of anti-trust violations, and IIRC the fines there were a bit steeper, and the EC forced them to finally provide real documentation for the Samba team to use to interoperate with Microsoft's Active Directory product.

Microsoft has started deliberate FUD campaigns against Linux, and other popular open-source software, they are widely suspected of provoking and funding the SCO lawsuits against IBM and Novell, and they corrupted the ISO standardization process to force their OOXML format through, so they could continue to sell Office to governments that were starting to demand compliance with open standards without significantly opening the software.

This 2009 paper from the European Committee for Interoperable Systems (ECIS) summarizes some of Microsoft's anticompetitive conduct up to that date. More recently, just look at how well Nokia has been doing since they got into bed with Microsoft! :lol:

In summary: I feel just as much antipathy toward Microsoft as Don does, I think they have worked hard to earn it. The only part of Microsoft that I actually like is their gaming division. They lock gamers and developers into their proprietary DRMed console platforms, but that's been SOP for a long time in the game industry and all of the other big vendors do it too so I don't fault them too much for that.
Exactly. The thing about this is that the same behavior by a real person would be considered psychopathic. There is no remorse, regret or apologies. We could go on and on about companies that actually do physical harm to people too - vigorous campaigns to get them hooked on products that harm them (tobacco comes to mind but there are many others) and many other psychopathic practices where companies are killing people for profit. Don't get me started.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: cross compiling

Post by Don »

Modern Times wrote:
Don wrote: The biggest issue is the Microsoft cocoon they put you in. The warm fuzzy feeling you get from knowing that Microsoft will always be there for you, and that you are part of something that most people will not disapprove of so that you are part of the crowd. So the Microsoft mentality has a way of promoting its own mediocrity.
That is exactly what I would have said about Apple, not Microsoft.
Apple is no different. Their angle is that their stuff is for "creative" people, the cool people, not the boring MS crowd. They have commercials that drive this concept home, the two guys that stand up and one represents Microsoft and the other hip young guy that represents Apple. They put a lot of humor into those commercials because it makes it more palatable and for many people it helps prevents people of exercising critical thinking. Most commercials in fact are designed to scam you out of money by suggesting things that are not true. If a person went around individually scamming people he would be jailed.

I do find Apples "message" very troubling because the only thing they really have over anyone else is snob appeal. Their products are overpriced for the substance although they tend to have more polish.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: cross compiling

Post by wgarvin »

Don wrote:Apple is no different. Their angle is that their stuff is for "creative" people, the cool people, not the boring MS crowd. They have commercials that drive this concept home, the two guys that stand up and one represents Microsoft and the other hip young guy that represents Apple. They put a lot of humor into those commercials because it makes it more palatable and for many people it helps prevents people of exercising critical thinking. Most commercials in fact are designed to scam you out of money by suggesting things that are not true. If a person went around individually scamming people he would be jailed.

I do find Apples "message" very troubling because the only thing they really have over anyone else is snob appeal. Their products are overpriced for the substance although they tend to have more polish.
Waaay off-topic now, but:

I stopped watching television over 10 years ago because I hated the commercials. They make up like 25-30% of all the screen time, and the entire purpose of a commercial is to convince me to buy something I otherwise wouldn't want to buy. Or at least to "subliminally" insert the idea that I might want this product, I might have a use for this product, if I need something to solve this problem I should think first of this product. [Edit: if you want to have these hot girls hanging around, drink this brand of beer! etc.] And I hate that, its like an attack on my own process of cognition. Everybody does commercial advertising, but we're at the extreme result of it where you get commercials for McDonalds that are designed by teams of psychologists and targeted at children to convince them to nag their parents to take them to McDonalds. Why does everyone willingly subject themselves to that crap? The very idea is offensive to me, its child abuse, its morally indefensible, any truly civilized society would outlaw TV commercials ! :shock: That will take another hundred years, so in the meantime I just settle for avoiding them.

In my early 20's I changed my habits to avoid all forms of advertising as much as possible: no cable TV (I watch movies or buy box sets of a few shows, but largely I just do without TV shows), no newspapers or magazines (I get my news from the internet where I can easily block any obnoxious ads) and no radio (Shoutcast streaming MP3 is always there if I want to hear some music). I suspect that I mindlessly consume less crap as a result, because I never see the commercials and get deluded into thinking I want those products. (When I actually do want to find a product for some purpose, I have the whole Internet to search.)

The only ads I get subjected to nowadays, are the commercials before the movie in theatres (seriously, wtf) and the unskippable crap at the beginning of some DVDs. At least, its unskippable on my player of choice, sigh... I got a box set of some Showtime show for Christmas which has like two minutes of unskippable crap before it lets you get to a menu and actually watch the show. Its incredibly anti-consumer, forcing people who paid for your product to suffer through the ads, while the pirates who torrent it are not saddled with such inconveniences. Oh well! :lol:
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: cross compiling

Post by Don »

wgarvin wrote:
Don wrote:Apple is no different. Their angle is that their stuff is for "creative" people, the cool people, not the boring MS crowd. They have commercials that drive this concept home, the two guys that stand up and one represents Microsoft and the other hip young guy that represents Apple. They put a lot of humor into those commercials because it makes it more palatable and for many people it helps prevents people of exercising critical thinking. Most commercials in fact are designed to scam you out of money by suggesting things that are not true. If a person went around individually scamming people he would be jailed.

I do find Apples "message" very troubling because the only thing they really have over anyone else is snob appeal. Their products are overpriced for the substance although they tend to have more polish.
Waaay off-topic now, but:

I stopped watching television over 10 years ago because I hated the commercials. They make up like 25-30% of all the screen time, and the entire purpose of a commercial is to convince me to buy something I otherwise wouldn't want to buy. Or at least to "subliminally" insert the idea that I might want this product, I might have a use for this product, if I need something to solve this problem I should think first of this product. [Edit: if you want to have these hot girls hanging around, drink this brand of beer! etc.] And I hate that, its like an attack on my own process of cognition. Everybody does commercial advertising, but we're at the extreme result of it where you get commercials for McDonalds that are designed by teams of psychologists and targeted at children to convince them to nag their parents to take them to McDonalds. Why does everyone willingly subject themselves to that crap? The very idea is offensive to me, its child abuse, its morally indefensible, any truly civilized society would outlaw TV commercials ! :shock: That will take another hundred years, so in the meantime I just settle for avoiding them.

In my early 20's I changed my habits to avoid all forms of advertising as much as possible: no cable TV (I watch movies or buy box sets of a few shows, but largely I just do without TV shows), no newspapers or magazines (I get my news from the internet where I can easily block any obnoxious ads) and no radio (Shoutcast streaming MP3 is always there if I want to hear some music). I suspect that I mindlessly consume less crap as a result, because I never see the commercials and get deluded into thinking I want those products. (When I actually do want to find a product for some purpose, I have the whole Internet to search.)

The only ads I get subjected to nowadays, are the commercials before the movie in theatres (seriously, wtf) and the unskippable crap at the beginning of some DVDs. At least, its unskippable on my player of choice, sigh... I got a box set of some Showtime show for Christmas which has like two minutes of unskippable crap before it lets you get to a menu and actually watch the show. Its incredibly anti-consumer, forcing people who paid for your product to suffer through the ads, while the pirates who torrent it are not saddled with such inconveniences. Oh well! :lol:
I feel exactly the way you do. I do suffer through the commercials but I enjoy picking them apart - asking myself what connection are they trying to make. When you look at it with a critical mind you realize how ridiculously silly it is, how can people be so incredibly happy to buy some mundane product! But the sad thing is that it must work really well or they would invest millions into it!
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: cross compiling

Post by lucasart »

Modern Times wrote:Wylie, Apple are the new Microsoft, but 10 times worse.
Oh yes, that is so true. And the worst part is that people love them for it...
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
stevenaaus
Posts: 613
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: cross compiling

Post by stevenaaus »

Of course Apple are a hardware company and thats how they make profits, bu I have a lot of experience with OS X now. It's a lovely thing. Beautiful and easy to use (once you get used to it's gui's nuances), with the underlying power of Unix.

Most any mac/macbook, you can take a harddrive from it and put it in another macbook, and it will run straight away, no hassles or drm issues at all.

Programs bought made from the Apple Store just need you to log in with your Apple ID before they work. It's just great.

Their hardware seems quite reliable too. Bought, fixed and around eight of the things now.

Of course i like Steve Jobs, and think they're heading the way of most souless coorporations without him. But that's just one of the relatively few problems with capitalism. Along with total depletion of the worlds natural resources of course. :o
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: cross compiling

Post by lucasart »

Jim Ablett wrote:It's very easy to compile for Android/Arm if you use the Codesourcery toolchain and cross-compile on Windows or Linux.

You'll need the arm-none-linux-gnueabi (lite) version.

https://sourcery.mentor.com/GNUToolchain/release2323

There are a few things you will need to know though (adjustments to the makefile).

Code: Select all

gcc     = arm-none-linux-gnueabi-gcc

Code: Select all

g++    = arm-none-linux-gnueabi-g++

Code: Select all

make  = cs-make
And for cpu architecture use:

Code: Select all

-mtune=arm7
use

Code: Select all

-static
(may also rarely need)

Code: Select all

-static-libgcc
If code uses pthreads you will need to statically link the whole library with this:

Code: Select all

-Wl,--whole-archive -lpthread -Wl,--no-whole-archive

and use Gcc built-in intrinsics for Lsb() / Msb()

Code: Select all

inline int lsb(Bitboard b)
{
	
return __builtin_ffsll(b) - 1;

}

inline int msb(Bitboard b)
{
	
int64_t ret = sizeof(uint64_t) * CHAR_BIT - 1;
	return b ? ret - __builtin_clzll(b) : ret;
}
Jim.
OK I managed to compile for ARMv7 and Win64 as follows.

Code: Select all

arm-linux-gnueabi-g++ -static -mtune=armv7 ./src/*.cc -o ./bin/dc_arm7 -DNDEBUG -std=c++11 -O3 -flto -fno-rtti -Wall -s

x86_64-w64-mingw32-g++ -static ./src/*.cc -o ./bin/dc_win64.exe -DNDEBUG -std=c++0x -O3 -flto -fno-rtti -Wall -s
The executables are working correctly. I verified the Win64 one with Wine, and got the correct node count, as well as a speed in the expected range. I verified the ARMv7 executable by playing a few moves in Chess for Android with it on my phone (I don't know how to get an Android command line on my Linux machine to verify it, but I'm sure it's possible).

However, I am shocked at the size of the executables:
- Linux x86-64 is 76 KB only!
- Windows x86-64 is 760 KB !!
- Android (ARMv7) is just over 1 MB !!!

I don't know if this is a bug in GCC, but even if it statically links the "few" stdlibc++ I use, I can't imagine it would take 1 MB.

Also, removing the "-static" fails on both Windows and Android (compiles w/o error but executable doesn't run on the target plateform). I naively tried "-static-libstdc++" (reducing the size of the executable somewhat) but that failed too. So they *have* to be statically linked.

But I remember than my compile of DiscoCheck 3.7.1 for Win64 (code was in plain C as opposed to C++ now) was compiled with mingw-w64 without the "-static", and the executable was much smaller, and was working under Windows without screaming for missing DLLs.

Any idea how to get around that "-static" problem ?

PS: Teaches me a lessons for moving from C to C++. C is so much simpler and more portable, I never had these kinds of problems with C code...
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
jdart
Posts: 4420
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: cross compiling

Post by jdart »

I might add, if you don't want to cross-compile, you can spin up a 32-bit Linux or Windows environment in Amazon's EC2 (http://aws.amazon.com), built and test your stuff there, and then shut it down when you are done. It is cheap and fast (if you can use a micro size instance it is even free). They don't have OSx or ARM though.

--Jon
User avatar
Jim Ablett
Posts: 2390
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: cross compiling

Post by Jim Ablett »

However, I am shocked at the size of the executables:
- Linux x86-64 is 76 KB only!
- Windows x86-64 is 760 KB !!
- Android (ARMv7) is just over 1 MB !!!
Have you tried compressing the binary with Upx ?

http://upx.sourceforge.net/

I haven't tested it for Arm but it is listed as one of the supported formats.

Jim.
User avatar
abik
Posts: 824
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: cross compiling

Post by abik »

lucasart wrote: However, I am shocked at the size of the executables:
- Linux x86-64 is 76 KB only!
- Windows x86-64 is 760 KB !!
- Android (ARMv7) is just over 1 MB !!!
Dynamically linked binary for Android: 479K
Runs well on a Nexus 7:

Code: Select all

$ ./discocheck401-ab
uci
id name DiscoCheck 4.0.1
id author Lucas Braesch
option name Hash type spin default 32 min 1 max 8192
option name Clear Hash type button
uciok