occs-compilers-2014-spring / discussion

A place for discussion
0 stars 0 forks source link

GCC on OS X #10

Open ikehz opened 10 years ago

ikehz commented 10 years ago

Some of us made the decision to do development on our own machines, and it'd be grand to be able to run gcc. I'm running OS X 10.9 Mavericks, which ships with clang, (and a symlink from gcc to clang). When I run clang on this test, (which assembles on the lab machines,) I get:

scratch/notes_example.s:1:17: error: unexpected token in '.section' directive
.section .rodata
                ^

I tried installing gcc-4.9 with Homebrew, and I get this:

gcc-4.9 scratch/notes_example.s
scratch/notes_example.s:1:Expected comma after segment-name
scratch/notes_example.s:1:Rest of line ignored. 1st junk character valued 46 (.).
scratch/notes_example.s:2:Unknown pseudo-op: .string
scratch/notes_example.s:2:Rest of line ignored. 1st junk character valued 34 (").
scratch/notes_example.s:19:32-bit absolute addressing is not supported for x86-64
scratch/notes_example.s:19:cannot do signed 4 byte relocation
scratch/notes_example.s:28:32-bit absolute addressing is not supported for x86-64
scratch/notes_example.s:28:cannot do signed 4 byte relocation

Eek.

The lab machines are running gcc 4.6.3, so I'm going to try to install Homebrew's gcc-4.6 on my machine, and see what happens.

Is anyone having more success compiling on OS X than I am?

ikehz commented 10 years ago

After looking into this more, I'm just going to build to ELF format, which seems to be what Clang compiles to on OS X. More info in FSF's Using as.