help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: running GTK:: trying to compile gnu-smalltalk for Mac M1 with your s


From: c4t0
Subject: Re: running GTK:: trying to compile gnu-smalltalk for Mac M1 with your script
Date: Mon, 17 Oct 2022 00:06:10 +0000

Hello! grad you like it.

TIL MacOS won't let you compile stuff that needs an executable stack.
That's fine, is really the first way to make a program vulnerable:
overflow it stack with shellcode and when the function returns BANG! you
execute arbitrary code.

nevertheless, we won't be using in security sensitive places so ... 

you can try what this guy says on SO
https://stackoverflow.com/a/42332821
https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/BufferOverflows.html

if you add --allow_stack_execute to the 'export CFLAGS' line, I think it
should work. For further debugging, you can try to compile this code in
a temp folder somewhere:

test.c:

#include <stdio.h>
int foo (int (*f)(int)){
  return f(20);
}
int bar (int arg)
{
  int baz (int arg2) { return arg2 * arg; }
  return foo (& baz) + arg;
}
int main(){
  printf("%d\n", bar(2));
  return 0;
}

with something like

${CC} test.c

a friend of mine with mac tried and it tells him that you can't define
an inner function nested in another function. In my machine it just
warns that it needs an executable stack, but it compiles it and returns
a number (a very important one btw)

You should try that with

${CC} --allow_stack_execute

Chau!

On 2022-10-16 19:50, etienne delacroix wrote:
> I used your wonderful script to try compiling. gnu-smalltalk ( the
> previous version. from the current one ) .   on my Mac air M1 laptop. 
>   I worked much better than my previous attempt with existing scripts,
>  yet. eventually interrupted with the error:
> 
> ld: the target architecture doesn't support executable stacks
> 
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> 
> that's beyond me....does this mean that there is no hope to compile
> gnu-smalltalk for the Mac M1.  ?????
> 
> On Sun, Oct 16, 2022 at 11:36 PM <c4t0@riseup.net> wrote:
> 
>> Hi!
>>
>> I've checkouted last commit a couple of days ago:
>> dfe4b5660037c4d178853ee00458a75e51a88563
>>
>> compiled with this script:
>>
>> #!/bin/bash
>>
>> dst_dir="$(pwd)/build"
>>
>> export CFLAGS="$CFLAGS -ffat-lto-objects
>> -Wl,--allow-multiple-definition
>> -w"
>> autoreconf -iv
>> ./configure \
>> --prefix="${dst_dir}" \
>> --enable-gtk=yes \
>> --enable-preemption \
>> --with-readline \
>> --with-libltdl \
>> --with-system-libffi \
>> --with-system-libsigsegv \
>> --with-tk \
>> --with-tcl \
>> --with-x \
>> --without-emacs \
>> --enable-static
>> echo '#define USE_INTERP_RESULT 1' >> config.h
>> make -j6
>> make install
>>
>> Then tried to run gst-browser and it failed, so I tried to debug it,
>> by
>> first making a minimal test:
>>
>> $ echo "PackageLoader fileInPackage: 'GTK'." > test.st [1]
>> $ build/bin/gst test.st [1]
>>
>> and that gives:
>>
>> "Global garbage collection... done"
>> Loading package GLib
>> Loading package Cairo
>> Loading package GTK
>> Object: Namespace new: 32 "<0x7f97f519fa20>" error: Invalid argument
>> #GtkTreeModel: key not found
>> SystemExceptions.NotFound(Smalltalk.Exception)>>signal
>> (ExcHandling.st:254)
>> SystemExceptions.NotFound(Smalltalk.Exception)>>signal:
>> (ExcHandling.st:264)
>> SystemExceptions.NotFound class>>signalOn:what: (SysExcept.st:736)
>> [] in Smalltalk.Namespace(Smalltalk.Dictionary)>>at:
>> (Dictionary.st:139)
>> Smalltalk.Namespace>>at:ifAbsent: (Namespace.st:160)
>> Smalltalk.Namespace(Smalltalk.Dictionary)>>at: (Dictionary.st:138)
>> [] in Smalltalk.CType class>>from: (CType.st:126)
>> Smalltalk.IdentityDictionary(Smalltalk.LookupTable)>>at:ifAbsent:
>> (LookupTable.st:86)
>> Smalltalk.CType class>>from: (CType.st:126)
>> Smalltalk.CPtrCType class>>from: (CType.st:327)
>> Smalltalk.CType class>>computeAggregateType: (CType.st:140)
>> Smalltalk.CType class>>from: (CType.st:121)
>> [] in GtkTreeModelPointer class(Smalltalk.CCompound
>> class)>>declaration:inject:into: (CStruct.st:153)
>> Smalltalk.Array(Smalltalk.SequenceableCollection)>>do:
>> (SeqCollect.st:826)
>> GtkTreeModelPointer class(Smalltalk.CCompound
>> class)>>declaration:inject:into: (CStruct.st:169)
>> GtkTreeModelPointer class(Smalltalk.CStruct class)>>declaration:
>> (CStruct.st:249)
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/MoreFuncs.st:15: key
>> GtkAccelGroup not found
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/MoreFuncs.st:15:
>> expected
>> Eval, Namespace or class definition
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/MoreFuncs.st:22:
>> expected
>> expression
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:1: key
>> GtkTextBuffer not found
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:1: expected
>> Eval, Namespace or class definition
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:8: expected
>> expression
>>
>> It seems to be quite broken :(
>>
>> After tweaking around with build/share/smalltalk/GTK.star, namely
>> commenting some of the <filein>
>>
>> <package>
>> <name>GTK</name>
>> <namespace>GTK</namespace>
>> <prereq>Cairo</prereq>
>> <prereq>GLib</prereq>
>> <module>gst-gtk</module>
>>
>> <filein>GtkDecl.st</filein>
>> <filein>GtkImpl.st</filein>
>> </package>
>>
>> I can reduce the errors:
>>
>> $ build/bin/gst test.st [1]
>> "Global garbage collection... done"
>> Loading package GLib
>> Loading package Cairo
>> Loading package GTK
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:1: key
>> GtkTextBuffer not found
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:1: expected
>> Eval, Namespace or class definition
>> ./build/share/smalltalk/GTK.star#VFS.ZipFile/GtkImpl.st:8: expected
>> expression
>>
>> The first error can be "solved" by adding the class definition in
>> GtkDecl.st:
>>
>> Object subclass: GtkTextBuffer [
>> <category: 'Gtk'>
>> <comment: nil>
>> ]
>>
>> and so on with the other errors that pop ups... obviously I'm
>> shooting
>> in the dark here and something is missing, be it configuration,
>> compilation options, libraries or code I don't quite know. It seems
>> that
>> all the libraries, headers and binaries are in place and the
>> problems
>> are to be found in ST code.
>> Where are the cCalls of all those classes? For instance, where are
>> all
>> the bindings for GtkTextBuffer?
>>
>> https://developer-old.gnome.org/gtk2/stable/GtkTextBuffer.html
>>
>> I found out of this project a while ago and I find rather
>> interesting
>> the idea to use Emacs for smalltalk programming, building apps with
>> gtk
>> support, and using a graphical browser to aid development instead of
>> being forced to use it. Emacs could use Smalltalk-in-Smalltalk
>> package
>> to provide auto-completion via company-mode, etc. It a shame that
>> this
>> project is so abandoned.
>>
>> So any help to get GTK bindings working or understanding the code
>> base
>> and what needs to be done in case that more coding is needed, as
>> well at
>> what setup do dev use for GST coding, would be appreciated.
>>
>> Bye!
>  
> 
> Links:
> ------
> [1] http://test.st



reply via email to

[Prev in Thread] Current Thread [Next in Thread]