Skip to content

Conversation

@Khushboo-dev-cpp
Copy link
Collaborator

@Khushboo-dev-cpp Khushboo-dev-cpp commented Dec 9, 2025

This PR is needed to make sure libsds.dylib is built with the proper architecture on any macos machine

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

Thanks for it! 🙌
I just added a tiny question so far

sds.nimble Outdated
let outLibNameAndExt = "libsds.dylib"
let name = "libsds"

let arch = hostCPU
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we expecting this attribute to be adapted manually?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its a constant coming from nim

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting! I wasn't aware of that :D

sds.nimble Outdated
let name = "libsds"

let arch = hostCPU
let archFlags = (if arch == "arm64": "--cpu:arm64 --passC:\"-arch arm64\" --passL:\"-arch arm64\""
Copy link

@alexjba alexjba Dec 10, 2025

Choose a reason for hiding this comment

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

I had to add the isysroot as well..No idea why it's not being picked automatically.

This made it work for me:

diff --git a/sds.nimble b/sds.nimble
index c683f4a..d1b43f4 100644
--- a/sds.nimble
+++ b/sds.nimble
@@ -1,5 +1,7 @@
 mode = ScriptMode.Verbose
 
+import strutils
+
 # Package
 version = "0.1.0"
 author = "Waku Team"
@@ -64,8 +66,9 @@ task libsdsDynamicMac, "Generate bindings":
   let name = "libsds"
 
   let arch = hostCPU
-  let archFlags = (if arch == "arm64": "--cpu:arm64 --passC:\"-arch arm64\" --passL:\"-arch arm64\""
-                   else: "--cpu:amd64 --passC:\"-arch x86_64\" --passL:\"-arch x86_64\"")
+  let sdkPath = staticExec("xcrun --show-sdk-path").strip()
+  let archFlags = (if arch == "arm64": "--cpu:arm64 --passC:\"-arch arm64\" --passL:\"-arch arm64\" --passC:\"-isysroot " & sdkPath & "\" --passL:\"-isysroot " & sdkPath & "\""
+                   else: "--cpu:amd64 --passC:\"-arch x86_64\" --passL:\"-arch x86_64\" --passC:\"-isysroot " & sdkPath & "\" --passL:\"-isysroot " & sdkPath & "\"")
 
   buildLibrary outLibNameAndExt,
     name, "library/",
@@ -91,9 +94,11 @@ task libsdsStaticLinux, "Generate bindings":
 task libsdsStaticMac, "Generate bindings":
   let outLibNameAndExt = "libsds.a"
   let name = "libsds"
+  let sdkPath = staticExec("xcrun --show-sdk-path").strip()
+  let sdkFlags = "--passC:\"-isysroot " & sdkPath & "\" --passL:\"-isysroot " & sdkPath & "\""
   buildLibrary outLibNameAndExt,
     name, "library/",
-    """-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
+    sdkFlags & " -d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE",
     "static"
 
 # Build Mobile iOS

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey status-im/status-app#19537 this change from Sid seems to solve the issue on macOS for me

Copy link

Choose a reason for hiding this comment

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

I guess the tricky question is why this PR is fixing the sds build? And why isn't it working out of the box without forcing the USE_SYSTEM_NIM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes exactly, there is an issue with this standalone library too, just building it on its own, complies it for x86_64, even on arm systems

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @alexjba , that's interesting
Thanks for the comments!
Kindly submit a separate PR with the fixes for .a
Cheers

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks so much indeed for it and the patience! 🥳

@Ivansete-status Ivansete-status merged commit ac31e5a into master Dec 15, 2025
1 check passed
@Ivansete-status Ivansete-status deleted the fix/buildForAppleSilicon branch December 15, 2025 11:06
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