Skip to content

eztrace: 1.1-11 -> 2.1.1 - #395939

Closed
0xda157 wants to merge 1 commit into
NixOS:masterfrom
0xda157:eztrace
Closed

0xda157 wants to merge 1 commit into
NixOS:masterfrom
0xda157:eztrace

Conversation

@0xda157

@0xda157 0xda157 commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

also unbreaks on gcc 14 #388196

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions Bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 4, 2025
@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 6, 2025
@petrzjunior

Copy link
Copy Markdown
Contributor

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 395939

Logs: https://github.com/petrzjunior/nixpkgs-review-gha/actions/runs/14296494925


x86_64-linux

✅ 1 package built:
  • eztrace

aarch64-linux

✅ 1 package built:
  • eztrace

x86_64-darwin

❌ 1 package failed to build:
  • eztrace

aarch64-darwin

❌ 1 package failed to build:
  • eztrace

@Sigmanificient Sigmanificient mentioned this pull request Apr 6, 2025
27 of 28 tasks
@github-actions github-actions Bot removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Apr 6, 2025
@0xda157

0xda157 commented Apr 6, 2025 •

Copy link
Copy Markdown
Contributor Author
Undefined symbols for architecture arm64:
  "___cyg_profile_func_enter", referenced from:
      _baz in foo.c.o
      _foo in foo.c.o
      _bar in foo.c.o
      _main in foo.c.o
  "___cyg_profile_func_exit", referenced from:
      _baz in foo.c.o
      _foo in foo.c.o
      _foo in foo.c.o
      _bar in foo.c.o
      _main in foo.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Not sure why this is happening on darwin (both arm and x86_64). Does anyone have any ideas?

@0xda157

0xda157 commented Apr 6, 2025

Copy link
Copy Markdown
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 395939

Logs: https://github.com/awwpotato/nixpkgs-review-gha/actions/runs/14296973438


x86_64-linux

✅ 2 packages built:
  • eztrace
  • gclient2nix

aarch64-linux

✅ 2 packages built:
  • eztrace
  • gclient2nix

x86_64-darwin

❌ 1 package failed to build:
  • eztrace
✅ 1 package built:
  • gclient2nix

aarch64-darwin

❌ 1 package failed to build:
  • eztrace
✅ 1 package built:
  • gclient2nix

@dblsaiko

Copy link
Copy Markdown
Contributor

I fixed the linker error on macOS, but pretty sure this is just broken on anything but Linux because it unconditionally imports Linux specific headers and I don't see a way to turn off compilation for this code: https://gitlab.com/eztrace/eztrace/-/blob/master/src/instrumentation/include/eztrace-instrumentation/tracing.h?ref_type=heads#L80

Said next error: https://gist.github.com/2xsaiko/7026ca51002895910fe5c4dc6f7c7a96

Either way, the linker error happens because it compiles with -finstrument-functions which makes the binary link against functions ___cyg_profile_func_enter and ___cyg_profile_func_exit, but these are not defined in the binary itself (on Linux, it looks like they are defined in glibc which is why it doesn't happen there), and then later at runtime overridden by eztrace. So, tell the linker to dynamically lookup missing symbols with -undefined dynamic_lookup.

I couldn't test if this actually works because of aforementioned further compile errors but it at least gets the build further.

Patch for the linker error:

Commit ID: a98c41831b98dbf660e615762d5c97ccc12166bd
Change ID: kqwwzxxzovqysqvwtrwkrrpqyznoktks
Author   : Marco Rebhan <[email protected]> (2025-04-17 14:32:56)
Committer: Marco Rebhan <[email protected]> (2025-04-17 14:44:41)

    (no description set)

diff --git a/pkgs/by-name/ez/eztrace/darwin-Fix-compiler-instrumentation-linker-error.patch b/pkgs/by-name/ez/eztrace/darwin-Fix-compiler-instrumentation-linker-error.patch
new file mode 100644
index 0000000000..2e1d25de3e
--- /dev/null
+++ b/pkgs/by-name/ez/eztrace/darwin-Fix-compiler-instrumentation-linker-error.patch
@@ -0,0 +1,23 @@
+Commit ID: 7fcffd58b5994d3411435deda07f5ca480747b38
+Change ID: vvwmpluqxrtspmkqwtrtnqoprwnnomtl
+Author   : Marco Rebhan <[email protected]> (2025-04-17 14:31:05)
+Committer: Marco Rebhan <[email protected]> (2025-04-17 14:31:05)
+
+    Fix compiler instrumentation test linker error
+
+diff --git a/test/compiler_instrumentation/CMakeLists.txt b/test/compiler_instrumentation/CMakeLists.txt
+index e8cfba5149..7afa367c70 100644
+--- a/test/compiler_instrumentation/CMakeLists.txt
++++ b/test/compiler_instrumentation/CMakeLists.txt
+@@ -5,6 +5,10 @@
+   set(CMAKE_C_FLAGS "-finstrument-functions -O0")
+   set(LINK_OPTIONS  "-rdynamic")
+ 
++  if (APPLE)
++    add_link_options("-Wl,-undefined,dynamic_lookup")
++  endif()
++
+   add_executable(foo foo.c)
+   add_test(build_foo "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target foo)
+ 
+
diff --git a/pkgs/by-name/ez/eztrace/package.nix b/pkgs/by-name/ez/eztrace/package.nix
index 42e382a4af..37f332c801 100644
--- a/pkgs/by-name/ez/eztrace/package.nix
+++ b/pkgs/by-name/ez/eztrace/package.nix
@@ -24,6 +24,10 @@
     otf2
   ];
 
+  patches = [
+    ./darwin-Fix-compiler-instrumentation-linker-error.patch
+  ];
+
   env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
 
   doInstallCheck = true;

Alternatively this to disable it, which gets you the same next compiler error:

Commit ID: b9342c0241b0b21cfad7d35418b9ec90c3011820
Change ID: kvytxvtvlkktusnynzqkmwvvuqqlkyrt
Author   : Marco Rebhan <[email protected]> (2025-04-17 14:40:40)
Committer: Marco Rebhan <[email protected]> (2025-04-17 14:40:40)

    (no description set)

diff --git a/pkgs/by-name/ez/eztrace/package.nix b/pkgs/by-name/ez/eztrace/package.nix
index 42e382a4af..e197db3de7 100644
--- a/pkgs/by-name/ez/eztrace/package.nix
+++ b/pkgs/by-name/ez/eztrace/package.nix
@@ -24,6 +24,10 @@
     otf2
   ];
 
+  cmakeFlags = lib.optionals stdenv.isDarwin [
+    "-DEZTRACE_ENABLE_COMPILER_INSTRUMENTATION=NO"
+  ];
+
   env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
 
   doInstallCheck = true;

@dblsaiko

Copy link
Copy Markdown
Contributor

Same when building outside of Nix with Xcode tools/homebrew. This isn't looking good for darwin support to me.

@0xda157

0xda157 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

Same when building outside of Nix with Xcode tools/homebrew. This isn't looking good for darwin support to me.

should I mark darwin as broken or remove it from the platforms?

@dblsaiko

Copy link
Copy Markdown
Contributor

I'm not sure when to use which. Broken, I suppose.

@0xda157
0xda157 requested a review from Prince213 April 17, 2025 20:34
@github-actions github-actions Bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Apr 17, 2025
@0xda157

0xda157 commented Apr 18, 2025

Copy link
Copy Markdown
Contributor Author

superseded by #388855

@0xda157 0xda157 closed this Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants