Opened 13 years ago

Closed 13 years ago

#33540 closed defect (invalid)

pstree: ld: can't write output file: pstree for architecture x86_64

Reported by: macports@… Owned by: mww@…
Priority: Normal Milestone:
Component: ports Version: 2.0.4
Keywords: Cc:
Port: pstree

Description (last modified by ryandesign (Ryan Carsten Schmidt))

# port install pstree
--->  Fetching archive for pstree
--->  Attempting to fetch pstree-2.33_1.darwin_11.x86_64.tbz2 from http://packages.macports.org/pstree
--->  Fetching pstree
--->  Verifying checksum(s) for pstree
--->  Extracting pstree
--->  Configuring pstree
--->  Building pstree
--->  Staging pstree into destroot
unable to read unknown load command 0x24
unable to read unknown load command 0x26
--->  Installing pstree @2.33_1
--->  Activating pstree @2.33_1
--->  Cleaning pstree

# pstree 
-sh: /opt/local/bin/pstree: Malformed Mach-o file

# file /opt/local/bin/pstree
/opt/local/bin/pstree: Mach-O executable x86_64

In main.log we have:

:debug:build Executing org.macports.build (pstree)
:debug:build Environment: CPATH='/opt/local/include' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/.CC_PRINT_OPTIONS' LIBRARY_PATH='/opt/local/lib' CC_PRINT_OPTIONS='YES' MACOSX_DEPLOYMENT_TARGET='10.7' GI_SCANNER_DISABLE_CACHE='1'
:debug:build Assembled command: 'cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33" && /usr/bin/make -j2 -w all'
:debug:build Executing command line:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33" && /usr/bin/make -j2 -w all 
:info:build make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33'
:info:build /usr/bin/clang -pipe -O1 -arch x86_64 -I/opt/local/include -L/opt/local/lib -arch x86_64 pstree.c -o pstree
:info:build ld: can't write output file: pstree for architecture x86_64
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)
:info:build make: *** [all] Error 1
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33'
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33" && /usr/bin/make -j2 -w all " returned error 2
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
    while executing
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for pstree): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for pstree is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/main.log

When omitting the "install" part, things seem to work:

# port build pstree
--->  Fetching pstree
--->  Verifying checksum(s) for pstree
--->  Extracting pstree
--->  Configuring pstree
--->  Building pstree

#  /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33/pstree | head -2
-+= 00001 root /sbin/launchd
 |--= 00010 root /usr/libexec/kextd

Attachments (1)

main.log (3.4 KB) - added by macports@… 13 years ago.
port install pstree

Download all attachments as: .zip

Change History (9)

Changed 13 years ago by macports@…

Attachment: main.log added

port install pstree

comment:2 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Owner: changed from macports-tickets@… to mww@…

It sounds like Xcode may not be installed properly. Could you uninstall and reinstall Xcode?

comment:3 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Summary: ld: can't write output file: pstree for architecture x86_64pstree: ld: can't write output file: pstree for architecture x86_64

comment:4 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

You did not mention what version of Xcode you have, but assuming it's 4.3 or later, ensure you also install the command line tools.

comment:5 Changed 13 years ago by macports@…

Oh, sorry, of course:

$ xcodebuild -version
Xcode 4.3
Build version 4E109

$ gcc --version | head -1
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)

But I don't know what this would have to do with Xcode? The actual compiling seems to go fine (see my example above), but MacPorts' install magic seems to do something strange. When compiling with MacPorts' own apple-gcc-4.2, the issue persists:

# port install pstree configure.compiler=apple-gcc-4.2
--->  Fetching archive for pstree
--->  Attempting to fetch pstree-2.33_1.darwin_11.x86_64.tbz2 from http://packages.macports.org/pstree
--->  Fetching pstree
--->  Verifying checksum(s) for pstree
--->  Extracting pstree
--->  Configuring pstree
--->  Building pstree
--->  Staging pstree into destroot
unable to read unknown load command 0x24
unable to read unknown load command 0x26
--->  Installing pstree @2.33_1
--->  Activating pstree @2.33_1
--->  Cleaning pstree

# /opt/local/bin/pstree 
-sh: /opt/local/bin/pstree: Malformed Mach-o file

comment:6 Changed 13 years ago by macports@…

FWIW, in case this wasn't clear, the following works just fine:

# port -d configure pstree
[...]

# cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_sysutils_pstree/pstree/work/pstree-2.33
# /usr/bin/clang -pipe -O1 -arch x86_64 -I/opt/local/include -L/opt/local/lib -arch x86_64 pstree.c -o pstree
# echo $?
0

# ./pstree | head -2
-+= 00001 root /sbin/launchd
 |--= 00010 root /usr/libexec/kextd

Even passing the environment options to clang (from "main.log" above) does not change a thing, the compilation still succeeds.

comment:7 Changed 13 years ago by macports@…

Anyway, I've uninstalled Xcode (plus the commandline tools):

$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer

$ xcodebuild -version
Xcode 4.3.1
Build version 4E1019

Unfortunately, this did not help, "port install pstree" still produces a "Malformed Mach-o file" :-\

comment:8 Changed 13 years ago by macports@…

While reinstalling Xcode did not help, reinstalling MacPorts did help and "pstree" now installs just fine. Sorry for the noise. (I cannot close this ticket, if anyone could do this, please?)

Thanks, C.

comment:9 Changed 13 years ago by mf2k (Frank Schima)

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.