Skip to content

symbol names: keep using . on non-Apple unix systems - #14143

Merged
Octachron merged 7 commits into
ocaml:trunkfrom
Octachron:stable_linux_mangling
Jul 21, 2025
Merged

symbol names: keep using . on non-Apple unix systems#14143
Octachron merged 7 commits into
ocaml:trunkfrom
Octachron:stable_linux_mangling

Conversation

@Octachron

Copy link
Copy Markdown
Member

As discussed in #14104, this PR proposes to revert to using . as module separator for symbol names on non-Apple unix systems — at the very least for OCaml 5.4.

This should restore the support of OCaml symbol name mangling in perf for OCaml 5.4, while keeping the lldb fix on Apple systems . Moreover, it seems likely to me that any tools analyzing symbol names already needs to have OS specific paths, thus we are hopefully not exporting a noticeable amount of complexity to those external tools.

cc @tmcgilchrist

Comment thread Changes Outdated
# now check the assembly file produced during compilation
asm=${test_build_directory}/func_sections.s
grep "\.section \.text\.caml\.camlFunc_sections\\$" "$asm" | wc -l | tr -d ' ' | sed '/^$/d'
grep "\.section \.text\.caml\.camlFunc_sections." "$asm" | wc -l | tr -d ' ' | sed '/^$/d'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using just . matches any character. I'm not sure this is what you had in mind. Maybe something like that instead?

Suggested change
grep "\.section \.text\.caml\.camlFunc_sections." "$asm" | wc -l | tr -d ' ' | sed '/^$/d'
grep "\.section \.text\.caml\.camlFunc_sections[.$]" "$asm" | wc -l | tr -d ' ' | sed '/^$/d'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a quick fix, but yes I agree it is better to narrow this grep.

Comment thread Changes Outdated
* #13050: Use '$' instead of '.' to separate module names in symbol names.
This changes mangling of OCaml identifiers from
* #13050, #14104, #?????: Use '$' instead of '.' to separate module names
in symbol names on Apple and non-unix operating systems.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think being more explicit about which platforms are affected would be a bit nicer:

Suggested change
in symbol names on Apple and non-unix operating systems.
in symbol names on macOS and Windows (including the Cygwin backend).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also slightly more correct since with the current code any new operating system will end up using . as a symbol name separator.

@xavierleroy xavierleroy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks! There may be some issues with a couple of tests, see below. Make sure to run a Jenkins CI precheck test.

Comment thread testsuite/tests/native-debugger/macos-lldb-amd64.reference
Comment thread testsuite/tests/native-debugger/macos-lldb-arm64.reference
Comment thread testsuite/tests/atomic-locs/cmm.compilers.reference
Comment thread middle_end/compilenv.mli Outdated
(* Return the module separator used when building symbol names. *)

val escape_prefix: string
(* Return the escape prefix for hexadecimal escape sequence. *)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, to be extra clear:

Suggested change
(* Return the escape prefix for hexadecimal escape sequence. *)
(* Return the escape prefix for hexadecimal escape sequences in symbol names. *)

@Octachron

Copy link
Copy Markdown
Member Author

Precheck is green on the OS/architecture only tested on the Inria side. I am thus planning to merge this afternoon in order to move forward with the beta for OCaml 5.4.0 .

@Octachron
Octachron merged commit ffa6197 into ocaml:trunk Jul 21, 2025
Octachron added a commit that referenced this pull request Jul 21, 2025
Sylvain78 pushed a commit to Sylvain78/ocaml that referenced this pull request Jul 29, 2025
damiendoligez added a commit to damiendoligez/ocaml that referenced this pull request Aug 22, 2025
OlivierNicole pushed a commit that referenced this pull request Aug 29, 2025
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

Successfully merging this pull request may close these issues.

4 participants