[fbsd_questions] i386 vs amd64, on intel_64
Dan Nelson
dnelson at allantgroup.com
Tue Oct 5 03:41:55 UTC 2010
In the last episode (Oct 05), spellberg_robert said:
> well, i looked at questions back to the beginning of august.
>
> on aug_09 i found a thread that suggests the following questions.
You might want to just use "i386" and "amd64" instead of making up your own
terminology ("i_386", "intel_64", "amd_64", etc). Note that Intel has chips
that support two competing 64-bit instruction sets: ia64, which is used by
their Itanium line, and amd64, which originated on AMD chips but Intel
adopted for their 64-bit-capable x86 chips (Xeon, Core etc). I'll assume
that any time you say "intel_64" or "amd_64" you really mean amd64, since
nobody uses Itaniums :)
> for a given release of freebsd,
>
> q: is it that the version labeled "i386" contains only 32_bit
> headers and source, which creates the 32_bit version of
> freebsd, as well as 32_bit versions of what i write, which will
> run as 32_bit code on either i_386, intel_64 or amd_64 ?
Yes, assuming you have COMPAT_FREEBSD32 in your kernel config (which GENERIC
has, so most people have it).
> q: is it that the version labeled "amd64" contains only 64_bit headers and source,
> which creates the 64_bit version of freebsd, as well as 64_bit
> versions of what i write, which will run as 64_bit code on the
> intel_64 and the amd_64, but, not the i_386 ?
Yes.
> q: if a "i386" version is installed on an intel_64 platform, then
> the pointers are 32_bits_wide, no matter what ?
Yes. FreeBSD's models are ILP32 (int, long, pointer are all 32-bit) or LP64
(int is 32-bit, long and pointer are 64-bit).
> q: if i want to produce both 32_bit and 64_bit versions of my
> "killer_app", then i need two machines,
> one a 32_bit or a 64_bit running "i386",
> the other --only-- a 64_bit running "amd64" ?
Or an amd64 machine with a 32-bit world installed in a subdirectory that you
can chroot to to do your 32-bit compiles, or a virtual machine running a
32-bit world.
> q: given that i have intel_64 hardware,
> do i need to start acquiring the "amd64" versions of the
> releases, rather_than / in_addition_to the "i386" versions ?
If you have more than 4GB of ram, it would be a good idea. If you have 4GB
or less, then 64-bit mode doesn't buy you much, and may cost you performance
since all your pointers take up twice the space, filling up your L1/L2
caches twice as fast.
> q: given that --i-- am committed to 64_bit hardware, perhaps, i
> should give up on the "i386" versions of the releases and
> require my users to spend us$_300 on 64_bit hardware [ it would
> save a large number of conditional_compilation directives;
> nudge_nudge, wink_wink, say no more
> ] ?
Or provide source and let the users compile what they need on their own
machines. Assuming you code using the appropriate types (size_t, intptr_t,
etc, or int32_t and int64_t for when you know you need a particular word
size) instead of assuming that a pointer will fit in an int, your code
should compile on either 32- or 64-bit machines with no conditional code.
http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list