[M3devel] cm3 on snow leopard?

Jay K jay.krell at cornell.edu
Sun Dec 12 07:01:21 CET 2010


Please try my updated Darwin.common.

IsX86 = equal(TARGET, "I386_DARWIN") or equal(TARGET, "AMD64_DARWIN")

proc configure_assembler() is
  if defined("SYSTEM_ASM")
    return
  end
  SYSTEM_ASM = "/usr/libexec/gcc/darwin/" & DarwinArch & "/as"
  if not FileExists(SYSTEM_ASM)
    if IsX86
      configure_c_compiler ()
      SYSTEM_ASM = SYSTEM_CC_ASM & " -c -x assembler"
    else
      SYSTEM_ASM = "as"
    end
  end
  %SYSTEM_ASM = SYSTEM_CC_ASM & " -v -c -x assembler"
end

proc configure_c_compiler() is

  if defined("SYSTEM_CC")
    return
  end

  %
  % older compiler doesn't like -m32 or -arch
  %
  % gcc -c -m32 -x c /dev/null
  % cc1: error: invalid option ‘m32’
  %
  % fPIC is not usually needed here.
  % It is the default for Apple gcc and left
  % here in case user is using a self-built FSF gcc.
  %

  SYSTEM_CC = "gcc -gstabs+ -fPIC"
  SYSTEM_CC_ASM = "gcc -fPIC"
  local m = " -m" & {"32BITS":"32","64BITS":"64"}{WORD_SIZE}
  local arch = " -arch " & DarwinArch
  if not equal(try_exec("@" & SYSTEM_CC & m & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: invalid option \\\`32'\" >/dev/null"), 0)
    SYSTEM_CC = SYSTEM_CC & m
    SYSTEM_CC_ASM = SYSTEM_CC_ASM & m
  end
  if not equal(try_exec("@" & SYSTEM_CC & arch & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: unrecognized command line option \\\\\"-arch\\\\\"\" >/dev/null"), 0)
    SYSTEM_CC = SYSTEM_CC & arch
    SYSTEM_CC_ASM = SYSTEM_CC_ASM & arch
  end
  %write("SYSTEM_CC is " & SYSTEM_CC)
end


 - Jay

From: jay.krell at cornell.edu
To: mika at async.caltech.edu; m3devel at elegosoft.com
Date: Sun, 12 Dec 2010 05:49:29 +0000
Subject: Re: [M3devel] cm3 on snow leopard?








I'm more sympathetic to using the already installed C compiler
to drive the assembler, than to build the current gcc driver.


You can see on Darwin we already probe around fairly aggressively
for a C compiler that can be told the target:

Darwin.common:


proc configure_c_compiler() is

  if defined("SYSTEM_CC")
    return
  end

  %
  % older compiler doesn't like -m32 or -arch
  %
  % gcc -c -m32 -x c /dev/null
  % cc1: error: invalid option ‘m32’
  %
  % fPIC is not usually needed here.
  % It is the default for Apple gcc and left
  % here in case user is using a self-built FSF gcc.
  %

  SYSTEM_CC = "gcc -gstabs+ -fPIC"
  local m = " -m" & {"32BITS":"32","64BITS":"64"}{WORD_SIZE}
  local arch = " -arch " & DarwinArch
  if not equal(try_exec("@" & SYSTEM_CC & m & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: invalid option \\\`32'\" >/dev/null"), 0)
    SYSTEM_CC = SYSTEM_CC & m
  end
  if not equal(try_exec("@" & SYSTEM_CC & arch & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: unrecognized command line option \\\\\"-arch\\\\\"\" >/dev/null"), 0)
    SYSTEM_CC = SYSTEM_CC & arch
  end
  %write("SYSTEM_CC is " & SYSTEM_CC)
end


Most likely if we merely set SYSTEM_ASM = SYSTEM_CC & "-x assembler"
it'll work well.
Maybe only in this else case:


proc configure_assembler() is
  if defined("SYSTEM_ASM")
    return
  end
  SYSTEM_ASM = "/usr/libexec/gcc/darwin/" & DarwinArch & "/as"
  if not FileExists(SYSTEM_ASM)
      SYSTEM_ASM = "as" <<== here
  end
end


All this is addressed by autoconf and/or a C-generating backend.....


 - Jay






From: jay.krell at cornell.edu
To: mika at async.caltech.edu; m3devel at elegosoft.com
Date: Sun, 12 Dec 2010 05:26:37 +0000
Subject: Re: [M3devel] cm3 on snow leopard?








I'm rudely (but helpfully) ignoring your details and giving some of mine.

I though what is supposed to happen, specifically on Darwin, is the assembly code is supposed to indicate an architecture.

jbook2:m3core jay$ CM3_TARGET=I386_DARWIN M3CONFIG=/cm3/bin/config/I386_DARWIN cm3 -keep
^C

jbook2:m3core jay$ CM3_TARGET=AMD64_DARWIN M3CONFIG=/cm3/bin/config/AMD64_DARWIN cm3 -keep
^C

head */RTHooks.ms

but no.

But then this:

jbook2:m3core jay$ CM3_TARGET=AMD64_DARWIN M3CONFIG=/cm3/bin/config/AMD64_DARWIN cm3 -keep -commands
--- building in AMD64_DARWIN ---

..
/usr/libexec/gcc/darwin/x86_64/as RTAllocator.ms -o RTAllocator.mo

CM3_TARGET=I386_DARWIN M3CONFIG=/cm3/bin/config/I386_DARWIN cm3 -keep -commands

...
/usr/libexec/gcc/darwin/i386/as Ctypes.is -o Ctypes.io

i386 vs. x86_64.

Darwin.common:
proc configure_assembler() is
  if defined("SYSTEM_ASM")
    return
  end
  SYSTEM_ASM = "/usr/libexec/gcc/darwin/" & DarwinArch & "/as"
  if not FileExists(SYSTEM_ASM)
      SYSTEM_ASM = "as"
  end
end


jbook2:m3core jay$ grep DarwinArch /dev2/cm3/m3-sys/cminstall/src/config-no-install/*
/dev2/cm3/m3-sys/cminstall/src/config-no-install/AMD64_DARWIN:DarwinArch = "x86_64"
/dev2/cm3/m3-sys/cminstall/src/config-no-install/ARM_DARWIN:DarwinArch = "armv6" % ?
/dev2/cm3/m3-sys/cminstall/src/config-no-install/Darwin.common:  SYSTEM_ASM = "/usr/libexec/gcc/darwin/" & DarwinArch & "/as"
/dev2/cm3/m3-sys/cminstall/src/config-no-install/Darwin.common:  local arch = " -arch " & DarwinArch
/dev2/cm3/m3-sys/cminstall/src/config-no-install/Darwin.common:      arch = " -arch_only " & DarwinArch & " "
/dev2/cm3/m3-sys/cminstall/src/config-no-install/I386_DARWIN:DarwinArch = "i386"
/dev2/cm3/m3-sys/cminstall/src/config-no-install/PPC64_DARWIN:DarwinArch = "ppc64"
/dev2/cm3/m3-sys/cminstall/src/config-no-install/PPC_DARWIN:DarwinArch = "ppc"

?
cm3 -commands?

find /usr/lib | grep /as$
find /usr/libexec | grep /as$


Maybe the path changed? Has a version? or is there is only i686-apple-darwin9, powerpc-apple-darwin9?

I should look into getting the architecture into the assembly code though and just running "as", esp. on newer hosts.

 - Jay


From: jay.krell at cornell.edu
To: mika at async.caltech.edu; m3devel at elegosoft.com
Date: Sun, 12 Dec 2010 00:59:18 +0000
Subject: Re: [M3devel] cm3 on snow leopard?








I admit I'm still using Leopard.

 - Jay



> To: m3devel at elegosoft.com
> Date: Sat, 11 Dec 2010 14:19:02 -0800
> From: mika at async.caltech.edu
> Subject: [M3devel] cm3 on snow leopard?
> 
> Hello m3devel,
> 
> I just tried to install CM3 from cm3-I386_DARWIN-REL.deb on a new MacBook
> Air, but it seems I have the wrong assembler?
> 
> I had to force dpkg to override the architecture on install (it was expecting
> i386, I think, and my machine identified itself as being "i386-darwin"?)
> 
> Here are some details...
> 
> [HAL:~/test/src] mika% /usr/local/cm3/bin/cm3 -version
> Critical Mass Modula-3 version 5.8.6
>   last updated: 2010-04-11
>   compiled: 2010-07-14 21:27:23
>   configuration: /usr/local/cm3/bin/cm3.cfg
>   host: I386_DARWIN
>   target: I386_DARWIN
> 
> compiling an empty Main.m3 yields:
> 
> [HAL:~/test/src] mika% /usr/local/cm3/bin/cm3 -keep -commands
> --- building in ../I386_DARWIN ---
> 
> cd ../I386_DARWIN
> rm .M3SHIP
> rm .M3OVERRIDES
> inhale prog.mx
> inhale /usr/local/cm3/pkg/m3core/I386_DARWIN/libm3core.a
> inhale /usr/local/cm3/pkg/libm3/I386_DARWIN/libm3.a
> 
> new source -> compiling Main.m3
> m3front ../src/Main.m3 -w1
> /usr/local/cm3//bin/cm3cg -funwind-tables -fPIC -gstabs+ -m32 -quiet -fno-reorde
> r-blocks Main.mc -o Main.ms
> echo "rep movsl" | as -o /dev/null 2> /dev/null
> as Main.ms -o Main.mo
> Main.ms:15:suffix or operands invalid for `push'
>   assemble => 1
> assembler failed assembling: Main.ms
> rm Main.mo
> exhale prog.mx
> rm prog.manifest
> 
> compilation failed => not building program "prog"
> Fatal Error: package build failed
> 
> [HAL:~/test/src] mika% uname -a
> Darwin HAL.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386
> [HAL:~/test/src] mika% as -v
> Apple Inc version cctools-782~33, GNU assembler version 1.38
> 
> 
> I have XCode installed.
> 
> [HAL:~/test/src] mika% gcc -v
> Using built-in specs.
> Target: i686-apple-darwin10
> Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
> Thread model: posix
> gcc version 4.2.1 (Apple Inc. build 5664)
> [HAL:~/test/src] mika% which gcc
> /usr/bin/gcc
> 
> 
> I must be doing something very obviously wrong (obviously to someone on this list, right??)
> 
>      Mika
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20101212/dd86234f/attachment-0002.html>


More information about the M3devel mailing list