Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a question #2

Closed
onixsosx opened this issue May 1, 2015 · 6 comments
Closed

a question #2

onixsosx opened this issue May 1, 2015 · 6 comments

Comments

@onixsosx
Copy link

onixsosx commented May 1, 2015

how to compile to support both i386 & x64bit?

Thanks

@tycho
Copy link
Owner

tycho commented May 1, 2015

I'm not sure what you're asking.

You can build a binary for either 32-bit or 64-bit but not both. But a 32-bit binary will run on both i386/x86_64.

$ make CC="gcc -m64"
    * rebuilding cpuid: new build flags or prefix
    CC cache.o
    CC clock.o
    CC cpuid.o
    CC feature.o
    CC handlers.o
    CC main.o
    CC sanity.o
    CC threads.o
    CC util.o
    GEN license.h
    GEN build.h
    CC version.o
    LD cpuid

$ file cpuid
cpuid: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=49c338f2211fca73f84b222ee789177e2e39478a, not stripped

$ make CC="gcc -m32"
    * rebuilding cpuid: new build flags or prefix
    GEN build.h
    DEPEND version.d
    DEPEND util.d
    DEPEND threads.d
    DEPEND sanity.d
    DEPEND main.d
    DEPEND handlers.d
    DEPEND feature.d
    DEPEND cpuid.d
    DEPEND clock.d
    DEPEND cache.d
    GEN build.h
    CC cache.o
    CC clock.o
    CC cpuid.o
    CC feature.o
    CC handlers.o
    CC main.o
    CC sanity.o
    CC threads.o
    CC util.o
    CC version.o
    LD cpuid

$ file cpuid
cpuid: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=db6ccc05d4c51e036e84f64bd345aeb0c13d58fe, not stripped

@onixsosx
Copy link
Author

onixsosx commented May 1, 2015

Hi!
Thank You for replying :)
x64 built ok but unsuccessful on x32

bash-3.2# make CC="gcc -m32"
* rebuilding cpuid: new build flags or prefix
CC cache.o
CC clock.o
CC cpuid.o
CC feature.o
CC handlers.o
CC main.o
CC sanity.o
CC threads.o
threads.c: In function ‘thread_count_native’:
threads.c:62: warning: unused parameter ‘state’
threads.c: In function ‘thread_bind_mask’:
threads.c:132: warning: unused parameter ‘_mask’
CC util.o
GEN license.h
GEN build.h
CC version.o
LD cpuid
ld: absolute addressing (perhaps -mdynamic-no-pic) used in _create_description from cache.o not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs
collect2: ld returned 1 exit status
make: *** [cpuid] Error 1
bash-3.2#

@onixsosx
Copy link
Author

onixsosx commented May 1, 2015

to follow up.. I am on Mac OS X

@tycho
Copy link
Owner

tycho commented May 1, 2015

Worth noting that CPUID's behavior won't be predictable on Mac OS X because they do not expose any thread affinity APIs (that's what the compiler warnings in threads.c are about -- those functions aren't actually implemented).

Why is it you're trying to do a 32-bit build on OS X, anyway? There were very few 32-bit Intel Macs released, and I believe they're unsupported these days. Assuming you have the build environment for it you could do something like CC="gcc -arch i386 -mmacosx-version-min=10.6", but I don't know how your build environment is set up.

@onixsosx
Copy link
Author

onixsosx commented May 1, 2015

I am trying to build for my older Macs which i believe are still x32.
I will continue to experiment on how I could build it in x32 Giving me the info above will surely help. :)

Thank You so much tycho

@tycho
Copy link
Owner

tycho commented May 1, 2015

Please note that "x32" is something entirely different -- the term you are looking for is "x86-32" or just "x86".

Let me know if you succeed.

@tycho tycho closed this as completed Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants