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

Compiling embedded Lua on macOS with Homebrew 'binutils' #136

Closed
spicyjack opened this issue Oct 24, 2021 · 2 comments
Closed

Compiling embedded Lua on macOS with Homebrew 'binutils' #136

spicyjack opened this issue Oct 24, 2021 · 2 comments

Comments

@spicyjack
Copy link

spicyjack commented Oct 24, 2021

Hi,

This issue is for informational purposes, I solved the original problem I had, however I wanted to suggest making a note of the below compile problems for RunCPM on macOS + Homebrew in the readme.md file for others who try to build RunCPM on macOS in the future.

I ran into a problem trying to build RunCPM on macOS Big Sur (11.2.3) with the Homebrew binutils package installed. Homebrew binutils includes it's own version of ar, which most likely would show up first in your $PATH before the Apple/macOS/Darwin system ar file (/usr/bin/ar). This will cause the following error when trying to build the bundled copy of Lua:

ld: warning: ignoring file liblua.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
  "_luaL_callmeta", referenced from:
      _msghandler in lua.o
...

The "fix" is to either edit the Makefile in the lua subdirectory, and hardcode the paths to both ar and ranlib to the system versions, or to remove /usr/local/bin from your $PATH while you're trying to build RunCPM.

Patch to Makefile in Lua subdir:

diff --git a/RunCPM/lua/Makefile b/RunCPM/lua/Makefile
index 514593d..355a85a 100644
--- a/RunCPM/lua/Makefile
+++ b/RunCPM/lua/Makefile
@@ -11,8 +11,8 @@ CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS)
 LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
 LIBS= -lm $(SYSLIBS) $(MYLIBS)
 
-AR= ar rcu
-RANLIB= ranlib
+AR= /usr/bin/ar rcu
+RANLIB= /usr/bin/ranlib
 RM= rm -f
 UNAME= uname

If you'd like, I can make a quick PR against readme.md with a short explanation of the above, I'm just not sure where I should put it; maybe in the "Building" section?

References

@MockbaTheBorg
Copy link
Owner

I will add a link to this issue, as the explanations are already all here.

@MockbaTheBorg
Copy link
Owner

done

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

No branches or pull requests

2 participants