Skip to content

Commit

Permalink
MacOS builds: for cross compiling make sure that getversion is compil…
Browse files Browse the repository at this point in the history
…ed for the

hostm not the target, as it must run on the host.  Eliminate an unnecessary
error report in sqUnixSpurMemory.c when launching on Apple Silicon with MAP_JIT.
[ci skip]
  • Loading branch information
eliotmiranda committed Jul 22, 2021
1 parent c0d1a55 commit 32aae72
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build.macos32x86/common/Makefile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ include ../common/Makefile.rules
svnver:
@-echo $(SVNREV)

# N.B. getversion is *not* cross compiled; it must run here and now
getversion: $(OSXCOMMONDIR)/version.c deps/version.d $(CROSSDIR)/sqSCCSVersion.h
$(CC) -x c -DVERSION_PROGRAM=1 $(ALLFLAGS) $(INCLUDES) $< -o $@
$(CC) -x c -DVERSION_PROGRAM=1 $(INCLUDES) $< -o $@
$(POSTCOMPILE)

-include deps/version.d
Expand Down
3 changes: 2 additions & 1 deletion build.macos64ARMv8/common/Makefile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ include ../common/Makefile.rules
svnver:
@-echo $(SVNREV)

# N.B. getversion is *not* cross compiled; it must run here and now
getversion: $(OSXCOMMONDIR)/version.c deps/version.d $(CROSSDIR)/sqSCCSVersion.h
$(CC) -x c -DVERSION_PROGRAM=1 $(ALLFLAGS) $(INCLUDES) $< -o $@
$(CC) -x c -DVERSION_PROGRAM=1 $(INCLUDES) $< -o $@
$(POSTCOMPILE)

-include deps/version.d
Expand Down
3 changes: 2 additions & 1 deletion build.macos64x64/common/Makefile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ include ../common/Makefile.rules
svnver:
@-echo $(SVNREV)

# N.B. getversion is *not* cross compiled; it must run here and now
getversion: $(OSXCOMMONDIR)/version.c deps/version.d $(CROSSDIR)/sqSCCSVersion.h
$(CC) -x c -DVERSION_PROGRAM=1 $(ALLFLAGS) $(INCLUDES) $< -o $@
$(CC) -x c -DVERSION_PROGRAM=1 $(INCLUDES) $< -o $@
$(POSTCOMPILE)

-include deps/version.d
Expand Down
10 changes: 9 additions & 1 deletion platforms/unix/vm/sqUnixSpurMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ sqDeallocateMemorySegmentAtOfSize(void *addr, sqInt sz)
* To cope with modern OSs that disallow executing code in writable memory we
* dual-map the code zone, one mapping with read/write permissions and the other
* with read/execute permissions. In such a configuration the code zone has
* already been alloated and is not included in (what is no longer) the initial
* already been allocated and is not included in (what is no longer) the initial
* alloc.
*/
static void
Expand Down Expand Up @@ -254,6 +254,10 @@ sqMakeMemoryExecutableFromToCodeToDataDelta(usqInt startAddr,
PROT_READ | PROT_EXEC) < 0)
perror("mprotect(x,y,PROT_READ | PROT_EXEC)");

# else if defined(MAP_JIT)

assert(!codeToDataDelta);

# else /* DUAL_MAPPED_CODE_ZONE */

if (mprotect((void *)firstPage,
Expand Down Expand Up @@ -283,7 +287,11 @@ allocateJITMemory(usqInt *desiredSize)

*desiredSize = roundUpToPage(*desiredSize);
result = mmap(hint, *desiredSize,
#if DUAL_MAPPED_CODE_ZONE
PROT_READ | PROT_EXEC,
#else
PROT_READ | PROT_WRITE | PROT_EXEC,
#endif
MAP_FLAGS | MAP_JIT, -1, 0);
if (result == MAP_FAILED) {
perror("Could not allocate JIT memory");
Expand Down

0 comments on commit 32aae72

Please sign in to comment.