ld linker freezes my computer

Summary:

Attempting to link a clang i386 object file into a Mac executable results in my computer becoming nonresponsive.

I inquired about assembling code with the GNU assembler (Gas AKA as). As Xcode contains an old linker, as 1.38, Apple advised using clang instead, per ticket 12408921 (https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/3/wo/UMrtsuR9aIxsbFCn1P0R4w/5.83.28.0.9).

Steps to Reproduce:

  1. Download the Hello World Gas code (https://github.com/mcandre/mcandre/tree/master/gas/hello/freebsd).
  2. Run “make”.

Expected Results:

  1. The object code is linked into an executable, and then the executable is run.

$ make
clang -c -o hello.o -arch i386 hello.s
ld -o hello -macosx_version_min 10.6 hello.o
./hello
Hello World!

Actual Results:

  1. The computer freezes up.

$ make
clang -c -o hello.o -arch i386 hello.s
ld -o hello -macosx_version_min 10.6 hello.o
(frozen)

Attempts to stop the linker with Control+C, quitting Terminal.app, Force Quit Applications, and Activity Monitor fail, as the system becomes too slow to process user input.

Specs:

  • ld64-134.9
  • clang 4.1
  • as 1.38
  • Xcode 4.5
  • Mac OS X 10.8.2
  • MacBook Pro 2009

Please don't post questions about tools distributed by Apple to
cfe-dev; this list is for development of clang and users of the clang
as distributed by llvm.org . devforums.apple.com is one appropriate
place to discuss Xcode and the associated tools.

-Eli

Just to verify, the computer does not actually freeze up, it just
slows to the point of unusability? This is an important distinction
to make, because the two situations have very different causes and
very different solutions.

Try running ‘top’ or the Activity Monitor window while you do this. It sounds like the linker is either consuming address space like crazy, or maybe forking like crazy.

In any case, as answered on your other thread, the program you’re trying to build isn’t going to work because it’s trying to use the Linux/BSD kernel call ABI instead of Mach’s. (But of course, the linker shouldn’t blow up like this even given bad input.)

—Jens

Attempts to stop the linker with Control+C, quitting Terminal.app, Force Quit Applications, and Activity Monitor fail, as the system becomes too slow to process user input.

Try running ‘top’ or the Activity Monitor window while you do this. It sounds like the linker is either consuming address space like crazy, or maybe forking like crazy.

My computer becomes very slow, too slow to type anything in Terminal.app, and too slow to launch the Activity Monitor.

In any case, as answered on your other thread, the program you’re trying to build isn’t going to work because it’s trying to use the Linux/BSD kernel call ABI instead of Mach’s. (But of course, the linker shouldn’t blow up like this even given bad input.)

This is discounted by the fact that the equivalent NASM code is fully functional in Mac OS X. Only the the GNU assembler syntax fails.

Start up the monitor before running the linker. Make sure both windows are visible.

—Jens