librelist archives

« back to archive

32bit vs. 64bit binaries

32bit vs. 64bit binaries

From:
David Reitter
Date:
2011-10-04 @ 02:59
Hi there,

I'm looking to upgrade to Homebrew, for two reasons.  

The first is that Macports annoyed me enough trying to build and install 
Perl, Python, Apache, what not.
This one is sufficiently answered and advertised.

The second one is that I keep having problems where libraries are built 
for either i386 or x86_64 architectures, while other targets are built 
against the other.  Of course, this won't link.  For example, this may 
happen when a point-and-click installer package provides libraries that 
are not universal (which is usually the case, at least within the two 
Intel architectures).

What is Homebrew's recipe for such cases?

Thanks
- David

PS.: Apologies if this is a dupe, couldn't find archives for this list.

Re: [homebrew] 32bit vs. 64bit binaries

From:
Charlie Sharpsteen
Date:
2011-10-04 @ 03:47
On Mon, Oct 3, 2011 at 7:59 PM, David Reitter <david.reitter@gmail.com>wrote:

> Hi there,
>
> I'm looking to upgrade to Homebrew, for two reasons.
>
> The first is that Macports annoyed me enough trying to build and install
> Perl, Python, Apache, what not.
> This one is sufficiently answered and advertised.
>
> The second one is that I keep having problems where libraries are built for
> either i386 or x86_64 architectures, while other targets are built against
> the other.  Of course, this won't link.  For example, this may happen when a
> point-and-click installer package provides libraries that are not universal
> (which is usually the case, at least within the two Intel architectures).
>
> What is Homebrew's recipe for such cases?
>
> Thanks
> - David
>
> PS.: Apologies if this is a dupe, couldn't find archives for this list.
>

Homebrew will build 64 bit binaries by default if your machine supports it
(all but the earliest Intel-based Macs do). Many formulae have a
`--universal` option that will trigger a universal build, a few do this by
default. There are some builds that are 32 bit only but they are very, very
rare.

So, to summarize---with Homebrew everything will be built for one
architecture, most likely x86_64.

Hope this helps!

-Charlie

Re: [homebrew] 32bit vs. 64bit binaries

From:
David Reitter
Date:
2011-10-04 @ 04:05
On Oct 3, 2011, at 11:47 PM, Charlie Sharpsteen wrote:
> 
> Homebrew will build 64 bit binaries by default if your machine supports 
it (all but the earliest Intel-based Macs do). Many formulae have a 
`--universal` option that will trigger a universal build, a few do this by
default. There are some builds that are 32 bit only but they are very, 
very rare.
> 
> So, to summarize---with Homebrew everything will be built for one 
architecture, most likely x86_64.
> 
> Hope this helps!

It's a clear answer, thanks.

So, when I have an i386 library installed, will a formula that builds, by 
default, a 64-bit binary, attempt to link against it and fail to build?
Or, will it install a 64-bit version of the library, shadowing the 
original one, and causing runtime failure of any i386 code that loads it 
dynamically?

Re: [homebrew] 32bit vs. 64bit binaries

From:
Charlie Sharpsteen
Date:
2011-10-04 @ 04:44
On Mon, Oct 3, 2011 at 9:05 PM, David Reitter <david.reitter@gmail.com>wrote:

> So, when I have an i386 library installed, will a formula that builds, by
> default, a 64-bit binary, attempt to link against it and fail to build?
> Or, will it install a 64-bit version of the library, shadowing the original
> one, and causing runtime failure of any i386 code that loads it dynamically?
>

If all your software components are coming from Homebrew, it would be very
rare (rare to the point of "this may be a bug") to have an i386 library
installed in the first place if your system can run 64-bit binaries. If you
are using Homebrew to build a formula, but expecting it to link against
libraries that were not provided by Homebrew (i.e. you are working on some
sort of personal project), we expect you know what you are doing, would be
well aware that the external library is i386 only, and would make the
appropriate adjustments.

-Charlie

Re: [homebrew] 32bit vs. 64bit binaries

From:
David Reitter
Date:
2011-10-04 @ 12:17
On Oct 4, 2011, at 12:44 AM, Charlie Sharpsteen wrote:

> If you are using Homebrew to build a formula, but expecting it to link 
against libraries that were not provided by Homebrew (i.e. you are working
on some sort of personal project), we expect you know what you are doing, 
would be well aware that the external library is i386 only, and would make
the appropriate adjustments.

If Homebrew was aware of the incompatibility of architectures, it would 
provide its own library in case one compiled with a different architecture
is already installed. 

A typical use case would be that a prior installation installs library X 
via a binary, point-and-click installer package (a common situation), and 
then I would brew-install Y, whereas Y depends on X.  As a user, I don't 
know about the dependency (being ignorant about that is the whole point).

If X is too old (version wise) for Y, then Homebrew would install a newer 
X, right?  If X has the wrong architecture, shouldn't Homebrew install a 
fat X with the additional architecture? 

Re: [homebrew] 32bit vs. 64bit binaries

From:
Misty De Meo
Date:
2011-10-04 @ 13:23
On Tue, Oct 4, 2011 at 7:17 AM, David Reitter <david.reitter@gmail.com> wrote:
> If Homebrew was aware of the incompatibility of architectures, it would 
provide its own library in case one compiled with a different architecture
is already installed.

It's usually recommended to always install all your libraries using
Homebrew, if available - it helps solve exactly this kind of problem.
Linking against binaries from other sources is really only something
you should do if you have a good reason to do it and you know why it
could possibly mess up. Like Charlie said, Homebrew tries to prevent
these sorts of issues by ensuring you get the right archs.

> A typical use case would be that a prior installation installs library X
via a binary, point-and-click installer package (a common situation), and 
then I would brew-install Y, whereas Y depends on X.  As a user, I don't 
know about the dependency (being ignorant about that is the whole point).
>
> If X is too old (version wise) for Y, then Homebrew would install a 
newer X, right?  If X has the wrong architecture, shouldn't Homebrew 
install a fat X with the additional architecture?

Homebrew installs its libraries into a special location (the "Cellar")
and symlinks them from there into /usr/local. It intentionally treats
libraries from elsewhere as though they're not installed, with a few
special exceptions - that helps ensure that Homebrew downloads and
builds the library in a way that should link correctly with other
libs, regardless of whether you have one installed already. That said,
keeping the old versions you installed around can still be trouble.
There's a builtin diagnostic tool called "brew doctor" which diagnoses
possible problems, including the presence of "unbrewed" libs which may
cause problems. It would be a good idea, once you install Homebrew, to
run brew doctor and delete any unbrewed libs it lists unless you're
really sure you need them for a special reason.