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

4.01.0dev emits compact unwind warnings since switch to clang #5921

Closed
vicuna opened this Issue Feb 13, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

commented Feb 13, 2013

Original bug ID: 5921
Reporter: @avsm
Assigned to: @mshinwell
Status: closed (set by @xavierleroy on 2015-12-11T18:29:29Z)
Resolution: fixed
Priority: normal
Severity: minor
OS: MacOS X
OS Version: 10.8
Version: 4.00.1
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.01.0
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Monitored by: meurer @ygrek @dbuenzli

Bug description

On latest MacOS X and trunk, any invocation of the linker results in warnings such as:

ld: warning: could not create compact unwind for _camlTypecore__add_pattern_variables_1925: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _camlTypecore__type_pattern_1937: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _camlTypecore__type_pattern_list_1949: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _camlTypecore__type_class_arg_pattern_1959: stack subq instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _camlTypecore__mkpat_1981: stack subq instruction is too different from dwarf stack size

The warnings can be suppressed by passing -no-compact-unwind to the linker:

--- a/configure
+++ b/configure
@@ -734,7 +734,8 @@ case "$arch,$nativecc,$system,$host_type" in
,,rhapsody,) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
if $arch64; then partialld="ld -r -arch ppc64"; fi;;
,gcc,cygwin,
) nativecccompopts="$gcc_warnings -U_WIN32";;

  • amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
  • amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64"
  •                   nativecccompopts="-Wl,-no_compact_unwind";;
    
    amd64,gcc*,solaris,) partialld="ld -r -m elf_x86_64";;
    ,gcc,
    ,*) nativecccompopts="$gcc_warnings";;
    esac

but I've not got an older 10.6/7 to see if this breaks anything there. Although I notice that trunk is also broken on 10.6 due to #5912

The above patch also still results in relocation warnings while bootstrapping the compiler.

Steps to reproduce

$ echo 'let _ = Printf.printf "foo%!"' > test.ml
$ ocamlopt -linkall test.ml
<warnings result on MacOS X 10.8>

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 26, 2013

Comment author: @damiendoligez

Reproduced on 10.7.5 with Xcode 4.5.1.
Your patch doesn't work (at least on my machine) because this part of the configuration script is totally messed up: the nativecccompopts variable is not used to link native executables.

We will need to clean up the configuration script and the "driver" part of the compilers.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 22, 2013

Comment author: @damiendoligez

In fact, $nativecccompopts is not used for linking executables. Nor is $nativecclinkopts (this is used only with ld for packing libraries). The flag must be put into both $mksharedlib and $mkexe.

I've done that and the warning disappeared (commit 13423 in trunk). Not tested on earlier versions of XCode. If they break and someone cares, we'll probably have to test for the presence of "clang" in the path before we add this flag.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 14, 2013

Comment author: @johnwhitington

This warning is now gone with 4.01.0 on Xcode 5 / OS X 10.9, without any patch.

However, we now have another rather abundant noisy warning:

ocamlfind ocamlc cpdflibwrapper.c;
clang: warning: argument unused during compilation: '-fno-defer-pop'

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 11, 2014

Comment author: @mshinwell

I think just silencing these warnings may have been a mistake; it might indicate an error in the DWARF information emitted by the OCaml compiler. I am going to investigate further later this week, since there has been recent evidence of problems in this area.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented May 7, 2015

Comment author: @mshinwell

I looked into this further. The problem appears to arise from code in the OS X linker that attempts to synthesize compact unwind sections from DWARF CFA information. I didn't manage to understand completely how it works, but I'm fairly sure it's tripping up on the OCaml CFA information because we don't have any callee-save registers.

There is a comment in recent versions of libunwind that suggests the OS X linker has stopped this behaviour since it is fragile (no surprises there). It wasn't clear from the latest version of the ld64 source code I looked at that this was the case, however. In any event, I think keeping compact unwind section generation disabled is the correct thing to do. If in future we wish to revisit this, the correct solution is very likely to have the OCaml compiler emit the compact unwind information directly. Then there should be no misunderstandings.

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added this to the 4.02.2 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.