gnustep / libobjc2 Goto Github PK
View Code? Open in Web Editor NEWObjective-C runtime library intended for use with Clang.
Home Page: http://www.gnustep.org/
License: MIT License
Objective-C runtime library intended for use with Clang.
Home Page: http://www.gnustep.org/
License: MIT License
Hi David,
We've discovered a fun little deadlock issue related to class initialisation. Assume two threads (1,2) and two classes (A,B) where A and B are unrelated, and A's +initialize sends a message to B:
Now you have a deadlock: Thread 1 is waiting for thread 2 to release the runtime lock and thread 2 is waiting for thread 1 to release the class lock.
I think it might be a solution to acquire the runtime lock before the objc_class_flag_initialized test on line 830 (and unlocking it right after taking the branch, before acquiring the class lock).
Hello,
It is not a issue, sorry in advance, however could you point me an updated article to install libobjc2 on Ubuntu 17.04? I would like to use blocks and ARC support as well.
Thanks in advance 👍
Not sure whether it libobjc2
issue or something else but now I can't build gnustep with the following error: gnustep/libs-base#23
Trying to run CMake with -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang -DCMAKE_ASM_COMPILER=clang -DCMAKE_ASM_FLAGS=-c -DTESTS=OFF -DOLDABI_COMPAT=OFF
I get a CMake warning:
CMake Warning:
Manually-specified variables were not used by the project:
OLDABI_COMPAT
When creating a root class, it looks like sizeof(struct objc_class)
is used rather than sizeof(struct objc_class *)
in runtime.c. This results in enough space being reserved for a full class to be stored inline in each instance, rather than just enough space for a pointer to one; 144 bytes in my testing.
I think the fix should be just:
diff --git a/runtime.c b/runtime.c
index 4352ccc..426a0d8 100644
--- a/runtime.c
+++ b/runtime.c
@@ -726,7 +726,7 @@ Class objc_allocateClassPair(Class superclass, const char *name, size_t extraByt
if (Nil == superclass)
{
- newClass->instance_size = sizeof(struct objc_class);
+ newClass->instance_size = sizeof(struct objc_class *);
}
else
{
But I haven't tested that. Hope this helps! :)
I upgraded to clang 3.7 (from 3.4, I think) last night, and I'm now getting a test failure in PropertyIntrospectionTest2. The test expects T@,R,N,VidReadonlyWeakNonatomic
, but what I get from the compiler (checked the binary) is now T@,R,W,N,VidReadonlyWeakNonatomic
. Since W
is the attribute char for weak properties, it seems to me that the test now expects the wrong thing (probably the weak attribute wasn't supported in earlier version of clang?).
We could make this conditional on the compiler version, but maybe there is a feature check macro that can be used? Or maybe we just want the test to fail on earlier versions of clang?
Is there a plan for a new release now?
What about building order and compiler to be used?
clang 3.1+, gnustep-make, -base, gui, back, libobjc2 or libobjc2 first?
(found the clang 3.1+ ref at https://en.wikipedia.org/wiki/Objective-C#Blocks)
However Debian (sid) has 6.0, 7, and 8
There is
https://github.com/gnustep/libobjc2/blob/master/ANNOUNCE.1.9 but I
can't find anything under releases...
Some distributions ship 1.8:
https://repology.org/metapackage/libobjc2/versions
I'm using the following commands to checkout, build, and install libobjc2, but recently this stopped working. Am I doing something wrong?
Step 7/12 : RUN git clone --depth 1 git://github.com/gnustep/libobjc2.git && cd ~/libobjc2 && mkdir Build && cd Build && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ && make -j4 && make install
---> Running in ca0cb34a10e4
Cloning into 'libobjc2'...
-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang
-- Testing C++ interop
-- Testing C++ standard library
-- libobjc will depend on C++ standard library
CMake Error at CMakeLists.txt:233 (target_sources):
Unknown CMake command "target_sources".
-- Configuring incomplete, errors occurred!
See also "/home/coderpad/libobjc2/Build/CMakeFiles/CMakeOutput.log".
The command '/bin/sh -c git clone --depth 1 git://github.com/gnustep/libobjc2.git && cd ~/libobjc2 && mkdir Build && cd Build && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ && make -j4 && make install' returned a non-zero code: 1
I just tried to update libobjc2 v1.8.1 to v2.0 by building the port on my BeagleBone Black, and it fails when linking the dynamic library:
FAILED: libobjc.so.4.6
: && /usr/local/bin/clang70 -fPIC -O -pipe -fno-strict-aliasing -Xclang -fexceptions -Xclang -fobjc-exceptions -O3 -O -pipe -fno-strict-aliasing -pthread
-shared -Wl,-soname,libobjc.so.4.6 -o libobjc.so.4.6 CMakeFiles/objc.dir/alias_table.c.o CMakeFiles/objc.dir/block_to_imp.c.o CMakeFiles/objc.dir/caps.c.o
CMakeFiles/objc.dir/category_loader.c.o CMakeFiles/objc.dir/class_table.c.o CMakeFiles/objc.dir/dtable.c.o CMakeFiles/objc.dir/encoding2.c.o
CMakeFiles/objc.dir/hooks.c.o CMakeFiles/objc.dir/ivar.c.o CMakeFiles/objc.dir/loader.c.o CMakeFiles/objc.dir/mutation.m.o CMakeFiles/objc.dir/protocol.c.o
CMakeFiles/objc.dir/runtime.c.o CMakeFiles/objc.dir/sarray2.c.o CMakeFiles/objc.dir/selector_table.c.o CMakeFiles/objc.dir/sendmsg2.c.o
CMakeFiles/objc.dir/eh_personality.c.o CMakeFiles/objc.dir/legacy.c.o CMakeFiles/objc.dir/abi_version.c.o CMakeFiles/objc.dir/statics_loader.c.o
CMakeFiles/objc.dir/block_trampolines.S.o CMakeFiles/objc.dir/objc_msgSend.S.o CMakeFiles/objc.dir/NSBlocks.m.o CMakeFiles/objc.dir/Protocol2.m.o
CMakeFiles/objc.dir/arc.m.o CMakeFiles/objc.dir/associate.m.o CMakeFiles/objc.dir/blocks_runtime.m.o CMakeFiles/objc.dir/properties.m.o
CMakeFiles/objc.dir/gc_none.c.o CMakeFiles/objc.dir/objcxx_eh.cc.o -lcxxrt && :
/usr/bin/ld: error: can't create dynamic relocation R_ARM_ABS32 against symbol: SmallObjectClasses in readonly segment; recompile object files with -fPIC
>>> defined in CMakeFiles/objc.dir/class_table.c.o
>>> referenced by CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x104)
I am able to build it manually using the following CMake config in the build
directory which I created in the working copy of the present repository:
cmake -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,notext“ ..
I'm running into the same issue as described in here. A poster (David Chisnall) says he'll release 1.7.1 soon, but that was over a year ago and the latest version linked from gnustep.org is still 1.7. Is the newer release just poorly advertised?
Also, would it be possible to add git tags corresponding to releases?
I'm running Debian GNU/Linux 8 on a Qualcomm/Arrow Dragonboard 410C and am having trouble compiling libobjc2.
I'm using commit 2ea1111, and Clang 3.7 was apt-gotten.
linaro@linaro-alip:~/libobjc2/build$ uname -a
Linux linaro-alip 4.2.4-linaro-lt-qcom #1 SMP PREEMPT Fri Dec 4 12:42:30 UTC 2015 aarch64 GNU/Linux
Here is the output of make.
Scanning dependencies of target objc
[ 1%] Building C object CMakeFiles/objc.dir/abi_version.c.o
[ 2%] Building C object CMakeFiles/objc.dir/alias_table.c.o
[ 3%] Building C object CMakeFiles/objc.dir/block_to_imp.c.o
[ 4%] Building C object CMakeFiles/objc.dir/caps.c.o
[ 5%] Building C object CMakeFiles/objc.dir/category_loader.c.o
[ 6%] Building C object CMakeFiles/objc.dir/class_table.c.o
[ 7%] Building C object CMakeFiles/objc.dir/dtable.c.o
[ 8%] Building C object CMakeFiles/objc.dir/eh_personality.c.o
[ 9%] Building C object CMakeFiles/objc.dir/encoding2.c.o
[ 10%] Building C object CMakeFiles/objc.dir/hash_table.c.o
[ 11%] Building C object CMakeFiles/objc.dir/hooks.c.o
[ 12%] Building C object CMakeFiles/objc.dir/ivar.c.o
[ 13%] Building C object CMakeFiles/objc.dir/legacy_malloc.c.o
[ 14%] Building C object CMakeFiles/objc.dir/loader.c.o
[ 15%] Building CXX object CMakeFiles/objc.dir/mutation.m.o
[ 16%] Building C object CMakeFiles/objc.dir/protocol.c.o
[ 17%] Building C object CMakeFiles/objc.dir/runtime.c.o
[ 18%] Building C object CMakeFiles/objc.dir/sarray2.c.o
[ 19%] Building C object CMakeFiles/objc.dir/selector_table.c.o
[ 20%] Building C object CMakeFiles/objc.dir/sendmsg2.c.o
[ 21%] Building C object CMakeFiles/objc.dir/statics_loader.c.o
[ 22%] Building C object CMakeFiles/objc.dir/toydispatch.c.o
[ 23%] Building ASM object CMakeFiles/objc.dir/block_trampolines.S.o
[ 25%] Building ASM object CMakeFiles/objc.dir/objc_msgSend.S.o
[ 26%] Building C object CMakeFiles/objc.dir/NSBlocks.m.o
[ 27%] Building C object CMakeFiles/objc.dir/Protocol2.m.o
[ 28%] Building C object CMakeFiles/objc.dir/arc.m.o
[ 29%] Building C object CMakeFiles/objc.dir/associate.m.o
[ 30%] Building C object CMakeFiles/objc.dir/blocks_runtime.m.o
[ 31%] Building C object CMakeFiles/objc.dir/properties.m.o
[ 32%] Building C object CMakeFiles/objc.dir/gc_none.c.o
Linking C shared library libobjc.so
[ 32%] Built target objc
Scanning dependencies of target objcxx
[ 33%] Building CXX object CMakeFiles/objcxx.dir/objcxx_eh.cc.o
Linking C shared library libobjcxx.so
[ 33%] Built target objcxx
Scanning dependencies of target AllocatePair
[ 34%] Building CXX object Test/CMakeFiles/AllocatePair.dir/AllocatePair.m.o
Linking C executable AllocatePair
[ 34%] Built target AllocatePair
Scanning dependencies of target AllocatePair_optimised
[ 35%] Building CXX object Test/CMakeFiles/AllocatePair_optimised.dir/AllocatePair.m.o
Linking C executable AllocatePair_optimised
[ 35%] Built target AllocatePair_optimised
Scanning dependencies of target AssociatedObject
[ 36%] Building CXX object Test/CMakeFiles/AssociatedObject.dir/AssociatedObject.m.o
Linking C executable AssociatedObject
[ 36%] Built target AssociatedObject
Scanning dependencies of target AssociatedObject2
[ 37%] Building CXX object Test/CMakeFiles/AssociatedObject2.dir/AssociatedObject2.m.o
Linking C executable AssociatedObject2
[ 37%] Built target AssociatedObject2
Scanning dependencies of target AssociatedObject2_optimised
[ 38%] Building CXX object Test/CMakeFiles/AssociatedObject2_optimised.dir/AssociatedObject2.m.o
Linking C executable AssociatedObject2_optimised
[ 38%] Built target AssociatedObject2_optimised
Scanning dependencies of target AssociatedObject_optimised
[ 39%] Building CXX object Test/CMakeFiles/AssociatedObject_optimised.dir/AssociatedObject.m.o
Linking C executable AssociatedObject_optimised
[ 39%] Built target AssociatedObject_optimised
Scanning dependencies of target BlockImpTest
[ 40%] Building CXX object Test/CMakeFiles/BlockImpTest.dir/BlockImpTest.m.o
Linking C executable BlockImpTest
[ 40%] Built target BlockImpTest
Scanning dependencies of target BlockImpTest_optimised
[ 41%] Building CXX object Test/CMakeFiles/BlockImpTest_optimised.dir/BlockImpTest.m.o
Linking C executable BlockImpTest_optimised
[ 41%] Built target BlockImpTest_optimised
Scanning dependencies of target BlockTest_arc
[ 42%] Building CXX object Test/CMakeFiles/BlockTest_arc.dir/BlockTest_arc.m.o
[ 43%] Building CXX object Test/CMakeFiles/BlockTest_arc.dir/Test.m.o
Linking C executable BlockTest_arc
[ 43%] Built target BlockTest_arc
Scanning dependencies of target BlockTest_arc_optimised
[ 44%] Building CXX object Test/CMakeFiles/BlockTest_arc_optimised.dir/BlockTest_arc.m.o
[ 45%] Building CXX object Test/CMakeFiles/BlockTest_arc_optimised.dir/Test.m.o
Linking C executable BlockTest_arc_optimised
[ 45%] Built target BlockTest_arc_optimised
Scanning dependencies of target BoxedForeignException
[ 46%] Building CXX object Test/CMakeFiles/BoxedForeignException.dir/BoxedForeignException.m.o
Linking C executable BoxedForeignException
[ 46%] Built target BoxedForeignException
Scanning dependencies of target BoxedForeignException_optimised
[ 47%] Building CXX object Test/CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o
Linking C executable BoxedForeignException_optimised
[ 47%] Built target BoxedForeignException_optimised
Scanning dependencies of target CXXExceptions
[ 48%] Building CXX object Test/CMakeFiles/CXXExceptions.dir/CXXException.m.o
[ 50%] Building CXX object Test/CMakeFiles/CXXExceptions.dir/CXXException.cc.o
Linking C executable CXXExceptions
[ 50%] Built target CXXExceptions
Scanning dependencies of target CXXExceptions_optimised
[ 51%] Building CXX object Test/CMakeFiles/CXXExceptions_optimised.dir/CXXException.m.o
[ 52%] Building CXX object Test/CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o
Linking C executable CXXExceptions_optimised
[ 52%] Built target CXXExceptions_optimised
Scanning dependencies of target ExceptionTest
[ 53%] Building CXX object Test/CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o
Linking C executable ExceptionTest
[ 53%] Built target ExceptionTest
Scanning dependencies of target ExceptionTest_optimised
[ 54%] Building CXX object Test/CMakeFiles/ExceptionTest_optimised.dir/ExceptionTest.m.o
Linking C executable ExceptionTest_optimised
[ 54%] Built target ExceptionTest_optimised
Scanning dependencies of target ForeignException
[ 55%] Building CXX object Test/CMakeFiles/ForeignException.dir/ForeignException.m.o
Linking C executable ForeignException
[ 55%] Built target ForeignException
Scanning dependencies of target ForeignException_optimised
[ 56%] Building CXX object Test/CMakeFiles/ForeignException_optimised.dir/ForeignException.m.o
Linking C executable ForeignException_optimised
[ 56%] Built target ForeignException_optimised
Scanning dependencies of target Forward
[ 57%] Building CXX object Test/CMakeFiles/Forward.dir/Forward.m.o
Linking C executable Forward
[ 57%] Built target Forward
Scanning dependencies of target Forward_optimised
[ 58%] Building CXX object Test/CMakeFiles/Forward_optimised.dir/Forward.m.o
Linking C executable Forward_optimised
[ 58%] Built target Forward_optimised
Scanning dependencies of target ManyManySelectors
[ 59%] Building CXX object Test/CMakeFiles/ManyManySelectors.dir/ManyManySelectors.m.o
Linking C executable ManyManySelectors
[ 59%] Built target ManyManySelectors
Scanning dependencies of target ManyManySelectors_optimised
[ 60%] Building CXX object Test/CMakeFiles/ManyManySelectors_optimised.dir/ManyManySelectors.m.o
Linking C executable ManyManySelectors_optimised
[ 60%] Built target ManyManySelectors_optimised
Scanning dependencies of target MethodArguments
[ 61%] Building CXX object Test/CMakeFiles/MethodArguments.dir/MethodArguments.m.o
Linking C executable MethodArguments
[ 61%] Built target MethodArguments
Scanning dependencies of target MethodArguments_optimised
[ 62%] Building CXX object Test/CMakeFiles/MethodArguments_optimised.dir/MethodArguments.m.o
Linking C executable MethodArguments_optimised
[ 62%] Built target MethodArguments_optimised
Scanning dependencies of target NestedExceptions
[ 63%] Building CXX object Test/CMakeFiles/NestedExceptions.dir/NestedExceptions.m.o
Linking C executable NestedExceptions
[ 63%] Built target NestedExceptions
Scanning dependencies of target NestedExceptions_optimised
[ 64%] Building CXX object Test/CMakeFiles/NestedExceptions_optimised.dir/NestedExceptions.m.o
Linking C executable NestedExceptions_optimised
[ 64%] Built target NestedExceptions_optimised
Scanning dependencies of target NilException
[ 65%] Building CXX object Test/CMakeFiles/NilException.dir/NilException.m.o
Linking C executable NilException
[ 65%] Built target NilException
Scanning dependencies of target NilException_optimised
[ 66%] Building CXX object Test/CMakeFiles/NilException_optimised.dir/NilException.m.o
Linking C executable NilException_optimised
[ 66%] Built target NilException_optimised
Scanning dependencies of target PropertyAttributeTest
[ 67%] Building CXX object Test/CMakeFiles/PropertyAttributeTest.dir/PropertyAttributeTest.m.o
Linking C executable PropertyAttributeTest
[ 67%] Built target PropertyAttributeTest
Scanning dependencies of target PropertyAttributeTest_optimised
[ 68%] Building CXX object Test/CMakeFiles/PropertyAttributeTest_optimised.dir/PropertyAttributeTest.m.o
Linking C executable PropertyAttributeTest_optimised
[ 68%] Built target PropertyAttributeTest_optimised
Scanning dependencies of target PropertyIntrospectionTest
[ 69%] Building CXX object Test/CMakeFiles/PropertyIntrospectionTest.dir/PropertyIntrospectionTest.m.o
Linking C executable PropertyIntrospectionTest
[ 69%] Built target PropertyIntrospectionTest
Scanning dependencies of target PropertyIntrospectionTest2_arc
[ 70%] Building CXX object Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/PropertyIntrospectionTest2_arc.m.o
<inline asm>:1:27: error: unexpected token in argument list
mov fp, fp ; marker for objc_retainAutoreleaseReturnValue
^
<inline asm>:1:27: error: unexpected token in argument list
mov fp, fp ; marker for objc_retainAutoreleaseReturnValue
^
<inline asm>:1:27: error: unexpected token in argument list
mov fp, fp ; marker for objc_retainAutoreleaseReturnValue
^
<inline asm>:1:27: error: unexpected token in argument list
mov fp, fp ; marker for objc_retainAutoreleaseReturnValue
^
<inline asm>:1:27: error: unexpected token in argument list
mov fp, fp ; marker for objc_retainAutoreleaseReturnValue
^
5 errors generated.
Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/build.make:54: recipe for target 'Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/PropertyIntrospectionTest2_arc.m.o' failed
make[2]: *** [Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/PropertyIntrospectionTest2_arc.m.o] Error 1
CMakeFiles/Makefile2:1359: recipe for target 'Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/all' failed
make[1]: *** [Test/CMakeFiles/PropertyIntrospectionTest2_arc.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2
We currently keep track of where all of the weak references are so that we can zero them. We probably should simply keep a weak reference count and destroy the weak references lazily on read when they are deallocated.
(not sure this is the right place to ask, but here goes)
Hello,
I am trying to use ObjC with ARC, libdispatch and blocks on Linux. I believe I am seeing a problem where ivars are referenced incorrectly, or are being aliased. I have tried to reduce the problem to a very small example.
Last year, using Ubuntu 12.04 and clang 3.4 I built and used ObjC and libobjc2 successfully. I am trying to recreate a similar working environment on Debian 8. I installed clang from 'apt-get'. It is version 3.5.
Here is the program that illustrates the problem. The arrays are there to illustrate that gnustep-base seems to be working. The ivars 'i' and 'j' are problematic.
// #import <Foundation/Foundation.h>
@interface Thing : NSObject
@property (readwrite) int i;
// @property int pad1;
// @property int pad2;
@property (readwrite) int j;
@property (readwrite) NSMutableArray * arr;
@end
@implementation Thing
- (id) init {
if (self = [super init]) {
_i = 5;
_j = 17;
_arr = [[NSMutableArray alloc] init];
[_arr addObject:@"test1"];
[_arr addObject:@"test2"];
}
return self;
}
@end
int main(int argc, char *argv[])
{
NSLog(@"starting");
NSMutableArray *thing = [[NSMutableArray alloc] init];
[thing addObject:@"one"];
[thing addObject:@"two"];
[thing addObject:@"three"];
NSLog(@"array:%@", thing);
thing = [[NSMutableArray alloc] init];
NSLog(@"array:%@", thing);
Thing *t = [[Thing alloc] init];
NSLog(@"Thing:%@", t);
NSLog(@"i:%u", t.i);
NSLog(@"j:%u", t.j);
NSLog(@"arr:%@", t.arr);
}
2016-11-10 08:40:43.315 errorexample2[13183:13183] starting
2016-11-10 08:40:43.330 errorexample2[13183:13183] array:(one, two, three)
2016-11-10 08:40:43.332 errorexample2[13183:13183] array:()
2016-11-10 08:40:43.332 errorexample2[13183:13183] Thing:<Thing: 0x193d1c0>
2016-11-10 08:40:43.332 errorexample2[13183:13183] i:5
2016-11-10 08:40:43.332 errorexample2[13183:13183] j:17
2016-11-10 08:40:43.332 errorexample2[13183:13183] arr:(test1, test2)
2016-11-10 08:38:46.121 errorexample2[26516:26516] starting
2016-11-10 08:38:46.122 errorexample2[26516:26516] array:(one, two, three)
2016-11-10 08:38:46.122 errorexample2[26516:26516] array:()
2016-11-10 08:38:46.122 errorexample2[26516:26516] Thing:<Thing: 0x1f1e070>
2016-11-10 08:38:46.123 errorexample2[26516:26516] i:17
2016-11-10 08:38:46.123 errorexample2[26516:26516] j:17
2016-11-10 08:38:46.123 errorexample2[26516:26516] arr:(test1, test2)
2016-11-10 08:46:46.126 errorexample2[26553:26553] starting
2016-11-10 08:46:46.127 errorexample2[26553:26553] array:(one, two, three)
2016-11-10 08:46:46.127 errorexample2[26553:26553] array:()
2016-11-10 08:46:46.127 errorexample2[26553:26553] Thing:<Thing: 0x9d5070>
2016-11-10 08:46:46.128 errorexample2[26553:26553] i:10303216
2016-11-10 08:46:46.128 errorexample2[26553:26553] j:10303216
2016-11-10 08:46:46.128 errorexample2[26553:26553] arr:(test1, test2)
sudo apt -y install clang git ninja cmake libffi-dev libxml2-dev libgnutls28-dev libicu-dev libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev autoconf libtool libjpeg-dev libtiff-dev libffi-dev libcairo-dev libx11-dev libxt-dev libxft-dev libc++-dev
export CC=clang
export CXX=clang
# Checkout sources
git clone https://github.com/nickhutchinson/libdispatch.git
git clone https://github.com/gnustep/libobjc2.git
git clone https://github.com/gnustep/make
git clone https://github.com/gnustep/base.git
git clone https://github.com/gnustep/gui.git
git clone https://github.com/gnustep/back.git
cd libdispatch
mkdir build; cd build
make
sudo -E make install
cd libobjc2
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang -DCMAKE_ASM_COMPILER=clang -DTESTS=OFF
cmake --build .
sudo -E make install
export LDFLAGS=-L/usr/local/lib
cd make
./configure --enable-debug-by-default --with-layout=gnustep --enable-objc-nonfragile-abi
make
sudo -E make install
sudo ldconfig
cd base
make clean
./configure
export LD_LIBRARY_PATH=/usr/local/lib:/usr/GNUstep/Local/Library/Libraries
clang -g -o errorexample2 -x objective-c -fobjc-runtime=gnustep-1.8.1 -v -I/usr/local/include/objc -I/usr/GNUstep/Local/Library/Headers -f
objc-arc errorexample2.m Journal.m -L/usr/local/lib -L/usr/GNUstep/Local/Library/Libraries -lobjc -lgnustep-base -ldispatch
Any ideas or pointers are appreciated.
Thanks
https://travis-ci.org/gnustep/libs-gui/builds/384499982
...
Scanning dependencies of target ForwardDeclareProtocolAccess_legacy
[ 11%] Building C object Test/CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/ForwardDeclareProtocolAccess.m.o
[ 11%] Building C object Test/CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/ForwardDeclareProtocol.m.o
#0 0x0000000001a615c4 PrintStackTraceSignalHandler(void*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1a615c4)
#1 0x0000000001a618a6 SignalHandler(int) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1a618a6)
#2 0x00002b27fd3f0330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x0000000001d5fd36 (anonymous namespace)::CGObjCGNU::GenerateProtocolRef(clang::CodeGen::CodeGenFunction&, clang::ObjCProtocolDecl const*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1d5fd36)
#4 0x0000000001d32ce2 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1d32ce2)
#5 0x0000000001bd9268 clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1bd9268)
#6 0x0000000001bd6cc8 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1bd6cc8)
#7 0x0000000001bdf63c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1bdf63c)
#8 0x0000000001c1176d clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&, clang::Stmt const*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1c1176d)
#9 0x0000000001c1204e clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1c1204e)
#10 0x0000000001c262e8 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1c262e8)
#11 0x0000000001c204db clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1c204db)
#12 0x0000000001c281b8 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1c281b8)
#13 0x00000000022a6a4f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-5.0.0/bin/clang-5.0+0x22a6a4f)
#14 0x00000000022a40a2 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-5.0.0/bin/clang-5.0+0x22a40a2)
#15 0x00000000024d1d03 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-5.0.0/bin/clang-5.0+0x24d1d03)
#16 0x0000000001f3605f clang::FrontendAction::Execute() (/usr/local/clang-5.0.0/bin/clang-5.0+0x1f3605f)
#17 0x0000000001ee55d8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1ee55d8)
#18 0x0000000001fb2d96 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x1fb2d96)
#19 0x00000000008a1862 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-5.0.0/bin/clang-5.0+0x8a1862)
#20 0x000000000089f7f9 main (/usr/local/clang-5.0.0/bin/clang-5.0+0x89f7f9)
#21 0x00002b27fe68df45 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f45)
#22 0x000000000089c9e9 _start (/usr/local/clang-5.0.0/bin/clang-5.0+0x89c9e9)
Stack dump:
0. Program arguments: /usr/local/clang-5.0.0/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ForwardDeclareProtocol.m -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/travis/dependency_source/libobjc2/build/Test/CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/ForwardDeclareProtocol.m.gcno -resource-dir /usr/local/clang-5.0.0/lib/clang/5.0.0 -D GC_DEBUG -D GNUSTEP -D NO_LEGACY -D OLDABI_COMPAT=1 -D TYPE_DEPENDENT_DISPATCH -D __OBJC_RUNTIME_INTERNAL__=1 -I /home/travis/dependency_source/libobjc2 -D NDEBUG -U NDEBUG -internal-isystem /usr/local/include -internal-isystem /usr/local/clang-5.0.0/lib/clang/5.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -std=gnu99 -fdebug-compilation-dir /home/travis/dependency_source/libobjc2/build/Test -ferror-limit 19 -fmessage-length 80 -fblocks -fobjc-runtime=gnustep-1.7 -fobjc-dispatch-method=non-legacy -fobjc-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/ForwardDeclareProtocol.m.o -x objective-c /home/travis/dependency_source/libobjc2/Test/ForwardDeclareProtocol.m
1. <eof> parser at end of file
2. /home/travis/dependency_source/libobjc2/Test/ForwardDeclareProtocol.m:4:11: LLVM IR generation of declaration 'getProtocol'
3. /home/travis/dependency_source/libobjc2/Test/ForwardDeclareProtocol.m:4:11: Generating code for declaration 'getProtocol'
clang-5.0: error: unable to execute command: Segmentation fault (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-5.0.0/bin
clang-5.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-5.0: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-5.0: note: diagnostic msg: /tmp/ForwardDeclareProtocol-32b509.m
clang-5.0: note: diagnostic msg: /tmp/ForwardDeclareProtocol-32b509.sh
clang-5.0: note: diagnostic msg:
********************
make[2]: *** [Test/CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/ForwardDeclareProtocol.m.o] Error 254
make[1]: *** [Test/CMakeFiles/ForwardDeclareProtocolAccess_legacy.dir/all] Error 2
make: *** [all] Error 2
The command "./travis-deps.sh" failed and exited with 2 during .
Your build has been stopped.
Hi,
It looks like there is an issue with clang 6 compatibility related to cxa_allocate_exception and related stuff. I have patched the issue against 1.8 as well as a bunch of warnings. I think the warnings were taken care of in master but I am not sure if the cxa_allocate_exception was addressed. I didn't see any reported bugs related to this issue so I have opened this.
clang_cxa_allocate_exception.patch
diff -Naur libobjc2-1.8.1/CMakeLists.txt libobjc2-1.8.1.new/CMakeLists.txt
--- libobjc2-1.8.1/CMakeLists.txt 2015-08-07 04:33:40.000000000 -0700
+++ libobjc2-1.8.1.new/CMakeLists.txt 2018-04-03 13:55:39.233515034 -0700
@@ -7,6 +7,7 @@
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -fno-inline ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "-O3 ${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
+set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
set(libobjc_VERSION 4.6)
@@ -14,7 +15,7 @@
# Build configuration
add_definitions( -DGNUSTEP -D__OBJC_RUNTIME_INTERNAL__=1)
# Probably not needed anymore?
-add_definitions( -D_XOPEN_SOURCE=700 -D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
+add_definitions( -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE=1)
set(libobjc_ASM_SRCS
block_trampolines.S
diff -Naur libobjc2-1.8.1/Makefile libobjc2-1.8.1.new/Makefile
--- libobjc2-1.8.1/Makefile 2015-08-07 04:33:40.000000000 -0700
+++ libobjc2-1.8.1.new/Makefile 2018-04-03 13:52:44.593214733 -0700
@@ -18,7 +18,7 @@
#CFLAGS += -Wno-deprecated-objc-isa-usage
CXXFLAGS += -fPIC -fexceptions
CPPFLAGS += -DTYPE_DEPENDENT_DISPATCH -DGNUSTEP
-CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D__BSD_VISIBLE=1 -D_BSD_SOURCE=1
+CPPFLAGS += -D__OBJC_RUNTIME_INTERNAL__=1 -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE=1
ASMFLAGS += `if $(CC) -v 2>&1| grep -q 'clang' ; then echo -no-integrated-as ; fi`
I have a reproducible test case in which an exception thrown from Objective-C++ code eventually leads to a SIGABRT. The exception needs to be thrown through a particular chain of ObjC++ and ObjC stack frames. My original program used gnustep-base, but I have a small reproducer that depends only on libobjc2 - I will create a PR shortly and reference it here.
PR #36 added symlinks to the libBlocksRuntime specific header locations (Block.h and Block_private.h in the top level header directory of the install prefix).
I've just tried to upgrade the libdispatch version used in the travis CI script for gnustep-base to the Swift corelibs (read: not horribly outdated) one and wanted to take advantage of that. As it turns out, the symlinks don't work so well:
https://travis-ci.org/ngrewe/base/jobs/476074822
As you can see, they can't find Availability.h (which would be expected, since it's located in the objc subdirectory).
A possible fix would be to install compatibility headers (just #inlcude
ing the libobjc2 headers) instead of dumb symlinks.
Following example compiles properly, but causes an assertion at runtime:
#include <stdio.h>
#include <objc/runtime.h>
__attribute__((objc_root_class))
@interface BitfieldTest {
Class isa;
BOOL flag1:1;
BOOL flag2:1;
BOOL flag3:1;
}
@end
@implementation BitfieldTest
+ (id)alloc {
return class_createInstance(self, 0);
}
+ (id)new {
return [[self alloc] init];
}
- (id)init {
flag1 = YES;
flag2 = NO;
flag3 = YES;
return self;
}
- (void)describe {
printf("%d%d%d\n", flag1, flag2, flag3);
}
@end
int main() {
@autoreleasepool {
id test = [BitfieldTest new];
[test describe];
}
}
$ clang -g -fobjc-runtime=gnustep-1.8 -L/usr/local/lib/ -lobjc -Wl,-rpath=/usr/local/lib/ bitfields.m -o bitfields
$ ./bitfields
bitfields: /tmp/libobjc2/ivar.c:61: void objc_compute_ivar_offsets(Class): Assertion `ivar_size > 0' failed.
Aborted (core dumped)
But it works fine with other runtimes…
I'm seeing an access violation in the ARC reference counting fast path for blocks.
We end up reading sizeof(uintptr_t)
bytes before the beginning of a block instance before the fast_arc flag check on isa here: https://github.com/gnustep/libobjc2/blob/master/arc.m#L528
Hi David,
I just noticed that links for the archives in the 1.8.1 release notes still point to the 1.8 release.
Cheers,
Niels
I have an object which contains a 'struct stat' as an instance variable. The latest version of the runtime is allocating the correct amount of space for it (120 bytes on FreeBSD) but is setting the base address sixteen bytes hugher than it shiuld. Thus using the structure overflows into the following instance variables and corrupts them.
This only happens with the non-fragile ABI. Using the fragile ABI works fine.
Example code below - this prints out he addresses of the object, the istance varaoibles and the size of struct stat. Its easy to see that it is getting it wrong. I havent been able to identify which commit causes the issue yet, but I notice there have been several chnages to ivar layout from the comments.
File attached - complie with: cc -I/usr/local/include -L/usr/local/lib test.m -lobjc
I have a program that I'd like to run under gnustep on an Ubuntu Linux system, linking with libobjc.so.4.6, building with clang/llvm. The program builds without any obvious problems. However, when I try to run it, I get an immediate segmentation fault, even before the start of my main() method. The stack trace, which I've copied below, suggests a problem with startup memory allocation. I'm compiling with tcmalloc-gperftools-r218.
Please let me know if there's anything I might do to debug this, or if it's more likely a bug on my side.
#0 tcmalloc::ThreadCache::Init (this=0x81b098, tid=)
at src/thread_cache.cc:116
#1 0x0000000000481187 in tcmalloc::ThreadCache::NewHeap (tid=140737353975744) at src/thread_cache.cc:398
#2 0x000000000048100b in tcmalloc::ThreadCache::CreateCacheIfNecessary () at src/thread_cache.cc:375
#3 0x00000000004766ab in GetCache () at ./src/thread_cache.h:423
#4 (anonymous namespace)::do_malloc_no_errno (size=24) at src/tcmalloc.cc:1236
#5 0x00000000004ad1f2 in do_malloc_no_errno_or_cpp_alloc (size=24) at src/tcmalloc.cc:1167
#6 do_calloc (n=, elem_size=) at src/tcmalloc.cc:1253
#7 tc_calloc (n=, elem_size=) at src/tcmalloc.cc:1749
#8 0x00007ffff5e70251 in SparseArrayNewWithDepth () from /home/dlobron/build/clangport/akamai/common/lib/libobjc.so.4.6
#9 0x00007ffff5e7035e in SparseArrayNew () from /home/dlobron/build/clangport/akamai/common/lib/libobjc.so.4.6
#10 0x00007ffff5e70e3b in init_selector_tables () from /home/dlobron/build/clangport/akamai/common/lib/libobjc.so.4.6
#11 0x00007ffff5e6b916 in __objc_exec_class () from /home/dlobron/build/clangport/akamai/common/lib/libobjc.so.4.6
#12 0x00007ffff5e7511f in .objc_load_function () from /home/dlobron/build/clangport/akamai/common/lib/libobjc.so.4.6
#13 0x00007ffff7dea13a in call_init (l=, argc=argc@entry=3, argv=argv@entry=0x7fffffffe198, env=env@entry=0x7fffffffe1b8) at dl-init.c:78
#14 0x00007ffff7dea223 in call_init (env=, argv=, argc=, l=) at dl-init.c:36
#15 _dl_init (main_map=0x7ffff7ffe1c8, argc=3, argv=0x7fffffffe198, env=0x7fffffffe1b8) at dl-init.c:126
#16 0x00007ffff7ddb30a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
Ubuntu 18.04 Clang 6.0
Build script: http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux (16.04, 16.10, & 17.04 version)
Everything built OK,but will running the gui test program, it crashed.
GUITest: /home/xxx/GNUstep-build/libobjc2/protocol.h:85: struct objc_protocol_method_description *protocol_method_at_index(struct objc_protocol_method_description_list *, int): Assertion `l->size >= sizeof(struct objc_protocol_method_description)' failed.
The value of l->size is '0'.
LLDB backtrace:
__GI_raise(sig=2) at raise.c:51 frame #1: 0x00007ffff560e801 libc.so.6
__GI_abort at abort.c:79__assert_fail_base(fmt="%s%s%s:%u: %s%sAssertion
%s' failed.\n%n", assertion="l->size >= sizeof(struct objc_protocol_method_description)", file="/home/applesnake/gnustep/GNUstep-build/libobjc2/protocol.h", line=85, function=) at assert.c:92__GI___assert_fail(assertion=<unavailable>, file=<unavailable>, line=<unavailable>, function=<unavailable>) at assert.c:101 frame #4: 0x00007ffff5f92345 libobjc.so.4.6
protocol_method_at_index + 69get_method_description + 112 frame #6: 0x00007ffff5f92988 libobjc.so.4.6
protocol_getMethodDescription + 72GSProtocolGetMethodDescriptionRecursive(aProtocol=0x00007ffff6ba01b8, aSel="\xffffff8b\n", isRequired=YES, isInstance=YES) at GSObjCRuntime.m:827 frame #8: 0x00007ffff6587407 libgnustep-base.so.1.25
-[NSDistantObject methodSignatureForSelector:](self=0x0000000001153e18, _cmd=">\b", aSelector="\xffffff8b\n") at NSDistantObject.m:727GSFFIInvocationCallback(cif=0x00000000010bc290, retp=0x00007fffffffbc00, args=0x00007fffffffba60, user=0x0000000001139ca8) at GSFFIInvocation.m:538 frame #10: 0x00007ffff14d5b4f libffi.so.6
ffi_closure_unix64_inner + 399ffi_closure_unix64 + 70 frame #12: 0x00007ffff658d97d libgnustep-base.so.1.25
-[NSDistributedNotificationCenter(self=0x00000000010e1288, _cmd="\xffffff8d\n") _connect] at NSDistributedNotificationCenter.m:781-[NSDistributedNotificationCenter addObserver:selector:name:object:suspensionBehavior:](self=0x00000000010e1288, _cmd="\xffffff83\n", anObserver=0x00000000010ca4a8, aSelector="\xfffffff9?", notificationName=0x0000000000000000, anObject=0x00007ffff7abf5e8, suspensionBehavior=2) at NSDistributedNotificationCenter.m:341 frame #14: 0x00007ffff658af5f libgnustep-base.so.1.25
-[NSDistributedNotificationCenter addObserver:selector:name:object:](self=0x00000000010e1288, _cmd="\xffffffb3\x01", anObserver=0x00000000010ca4a8, aSelector="\xfffffff9?", notificationName=0x0000000000000000, anObject=0x00007ffff7abf5e8) at NSDistributedNotificationCenter.m:266-[_GSWorkspaceCenter init](self=0x00000000010ca4a8, _cmd="\xffffffcc") at NSWorkspace.m:349 frame #16: 0x00007ffff662bd92 libgnustep-base.so.1.25
+[NSObject new](self=0x0000000000797b40, _cmd="\xffffff9a") at NSObject.m:1237-[NSWorkspace init](self=0x00000000010cf4e8, _cmd="\xffffffcc") at NSWorkspace.m:752 frame #18: 0x00007ffff7577cf8 libgnustep-gui.so.0.26
+[NSWorkspace sharedWorkspace](self=0x0000000000797ec0, _cmd="\xffffffe2\x1d") at NSWorkspace.m:700-[NSApplication activateIgnoringOtherApps:](self=0x0000000000bf63a8, _cmd="\xffffffe8\x1c", flag=YES) at NSApplication.m:1334 frame #20: 0x00007ffff75673aa libgnustep-gui.so.0.26
-[NSWindow sendEvent:](self=0x0000000000d8f498, _cmd="\xffffffb9\x1c", theEvent=0x00000000010ce2c8) at NSWindow.m:4246-[NSApplication sendEvent:](self=0x0000000000bf63a8, _cmd="\xffffffb9\x1c", theEvent=0x00000000010ce2c8) at NSApplication.m:2126 frame #22: 0x00007ffff7273539 libgnustep-gui.so.0.26
-[NSApplication runModalSession:](self=0x0000000000bf63a8, _cmd="\xffffffbf\x1c", theSession=0x000000000108f270) at NSApplication.m:1875-[NSApplication runModalForWindow:](self=0x0000000000bf63a8, _cmd="2\e", theWindow=0x0000000000d8f498) at NSApplication.m:1763 frame #24: 0x00007ffff7253ef7 libgnustep-gui.so.0.26
-[NSAlert runModal](self=0x0000000000eefe78, _cmd="\xffffffec\x1a") at NSAlert.m:2016main at guitest.m:11 frame #26: 0x00007ffff55efb97 libc.so.6
__libc_start_main(main=(GUITestmain at guitest.m:4), argc=1, argv=0x00007fffffffdd08, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffdcf8) at libc-start.c:310 frame #27: 0x0000000000400a8a GUITest
_start + 42libobjc2's block headers are at objc/blocks_runtime.h
and objc/blocks_private.h
respectively, and I understand there must have been a good reason to keep them with these names instead of the ones in Apple's API. However, this breaks compatibility with a lot of applications that try to access block runtime declarations in this "standard" location, and building them requires manually setting up symlinks to these files.
Would it make sense to create Block.h
and Block_private.h
as symlinks to the GNUstep block headers in the install routine? The issue I can think of is generating conflicts with systems that ship with these headers (like OSX) or with other libraries that implement the block runtime (e.g. libBlocksRuntime on Linux), but it seems like these cases could be easily handled on the install routine.
I thought this might be interesting to report:
95% tests passed, 8 tests failed out of 158
Total Test time (real) = 28.51 sec
The following tests FAILED:
57 - PropertyAttributeTest (Child aborted)
58 - PropertyAttributeTest_optimised (Child aborted)
59 - PropertyAttributeTest_legacy (Child aborted)
60 - PropertyAttributeTest_legacy_optimised (Child aborted)
61 - ProtocolExtendedProperties (Child aborted)
62 - ProtocolExtendedProperties_optimised (Child aborted)
149 - category_properties (Child aborted)
150 - category_properties_optimised (Child aborted)
Errors while running CTest
FAILED: CMakeFiles/test.util
cd /Users/Ingwie/Work/Git/libobjc2/out && /usr/local/Cellar/cmake/3.13.4/bin/ctest --force-new-ctest-process
ninja: build stopped: subcommand failed.
[email protected] ~/W/G/l/out $ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D42
[email protected] ~/W/G/l/out $ cd ..; git rev-parse HEAD
d015f0160cfeb3097c8d2321c0bfc648c0885047
Hope it helps :)
/usr/local/include/ObjectiveC2/objc/runtime.h:146:1: error: unknown type name 'Method_t'; did you mean 'Method'?
Centos
command:
clang -fblocks -fobjc-nonfragile-abi main.m -o main
Newer versions of the Apple runtimes include a objc_unsafeClaimAutoreleasedReturnValue
function. This is equivalent to objc_retainAutoreleasedReturnValue, but returns the object without the retain. It's not clear from references to this function whether it gives an autoreleased reference, but I believe not.
The system is: FreeBSD 11.0-RELEASE-p3 amd64
The CPU is: Intel(R) Atom(TM) CPU D510 @ 1.66GHz (1666.72-MHz K8-class CPU)
The clang version is: FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
On the console I executed as root:
# svn checkout https://github.com/gnustep/libobjc2/trunk/ libobjc2
# cd libobjc2; mkdir build; cd build
# cmake ..
# make
# make test
Test project /root/install/libobjc2/build
Start 1: alignTest
1/52 Test #1: alignTest ..................................***Exception: Other 0.43 sec
Start 2: alignTest_optimised
2/52 Test #2: alignTest_optimised ........................***Exception: Other 0.38 sec
...
# Test/alignTest
--> self: 0x801829128 Addr: 0x801829140
--> Assertion failed: (o_isa == 0), function main, file /root/install/libobjc2/Test/alignTest.m, line 83.
--> Abort (core dumped)
All the other tests succeeded.
The current (1.8.1 and Git master) implementations of object_setInstanceVariable() trigger a Segault if the caller tries to set a non-existent ivar. This can happen when a NIB is loaded. A graceful exit with a NULL return value would seem to be better behavior.
With 1.8.x I fix this issue with the following:
void object_setIvar(id object, Ivar ivar, id value)
{
char *addr = (char*)object;
+ unsigned offset;
+ if (ivar && (offset = ivar_getOffset(ivar)))
+ {
- addr += ivar_getOffset(ivar);
+ addr += offset;
*(id*)addr = value;
+ }
}
The Git master code also blows up when determining the encoding type of a non-existent ivar:
Ivar object_setInstanceVariable(id obj, const char *name, void *value)
{
Ivar ivar = class_getInstanceVariable(object_getClass(obj), name);
--> if (ivar_getTypeEncoding(ivar)[0] == '@')
I recently compiled an Objective-C program on Linux using clang/llvm . I'm using libobjc2-1.8.1, with llvm 3.7. My program links with a shared library (also written in ObjC), which introspects the instance variables in a common Configuration class to determine what type each of those variables is. This has always worked on the Mac with clang and on Linux with gcc. However, with clang/llvm on Linux, I'm finding that the type introspection fails. The shared library code looks like this:
Ivar *ivarList = class_copyIvarList(c, &ivarCount);
for (i = 0; i < ivarCount; i++) {
Ivar ivar = ivarList[i];
const char *ivarCname = ivar_getName(ivar);
if (ivarCname != 0 && ivarCname[0] != '_') {
NSString *ivarName = [NSString stringWithUTF8String:ivarCname];
const char *ivarType = ivar_getTypeEncoding(ivar);
bool isObjectValuedIvar = (ivarType[0] == '@' && ivarType[1] == '"')
if (isObjectValuedIvar) {
NSString *className = [[[NSString alloc] initWithBytes: &ivarType[2]
length: strlen(&ivarType[2])-1
encoding: NSUTF8StringEncoding] autorelease];
Class c = NSClassFromString(className);
I'm finding that the call to ivar_getTypeEncoding returns "@" in the ivarType variable. However, that variable only contains "@". It doesn't have any element 1 or 2, and my code seg faults when I try to access them. I ran the code under gdb with optimization turned off, and verified that the ivarCname and ivarType variables contain the variable name and "@", respectively:
(gdb) print ivarCname
$9 = 0x4a4575 "sslCertificateFile"
(gdb) print ivarType
$5 = 0x4a5951 "@"
Should the call to ivar_getTypeEncoding be returning more than "@"?
Another oddity here is that the ivar object itself seems opaque. I can't seem to print the struct members:
(gdb) print ivar
$12 = (Ivar) 0x6e1160 <.objc_ivar_list+776>
(gdb) print ivar.name
There is no member named name.
(gdb) print ivar.type
There is no member named type.
(gdb) print ivar->type
There is no member named type.
I'm not sure how this is possible, because the ivar_getTypeEncoding function just does this:
const char * ivar_getTypeEncoding(Ivar ivar)
{
CHECK_ARG(ivar);
return ivar->type;
}
I'd appreciate any help here! I'm wondering if my code is somehow finding different versions of the runtime - I'm not sure how I can determine that beyond using gdb.
I started getting this error trying to compile Objective-C recently:
In file included from /usr/GNUstep/Local/Library/Headers/Foundation/Foundation.h:33:
In file included from /usr/GNUstep/Local/Library/Headers/Foundation/FoundationErrors.h:29:
In file included from /usr/GNUstep/Local/Library/Headers/Foundation/NSObject.h:30:
In file included from /usr/GNUstep/Local/Library/Headers/Foundation/NSObjCRuntime.h:41:
/usr/GNUstep/Local/Library/Headers/GNUstepBase/GSBlocks.h:123:7: error: conflicting types for '_Block_copy'
void *_Block_copy(void *) __attribute__((weak));
^
/usr/GNUstep/Local/Library/Headers/objc/blocks_runtime.h:16:21: note: previous declaration is here
BLOCKS_EXPORT void *_Block_copy(const void *);
Most likely caused by this 5f01917 commit.
Apple's "new" runtime needs objc_msgSend()
to be cast to the appropriate function pointer type before calling it. This seems to be necessary as - as I understood it - the calling convention is different on some platforms with actual parameters and with variadic parameters.
What about GNUStep's (and GCC's)? Does it need to be cast as well? Also, if it doesn't need, does it support it? (I'm asking it here for documentation purposes, as I could probably infer this information from the assembly code within a few... hours, days?)
I'm asking that because I'm currently working on a research compiler with support for Objective-C, which itself largely depends on libobjc. I want to simplify portability issues as much as I can.
You added this patch on your fork: davidchisnall/libobjc2@71c1437 that I thought would be in 1.8, but it doesn't appear to be there. Was this intentional? It's preventing me from building on newer Clang.
While I have set the CMAKE_C_COMPILER to clang, it reports that
[ 17%] Building C object CMakeFiles/objc.dir/sendmsg2.c.o
[ 18%] Building C object CMakeFiles/objc.dir/statics_loader.c.o
[ 18%] Building C object CMakeFiles/objc.dir/toydispatch.c.o
[ 19%] Building ASM object CMakeFiles/objc.dir/block_trampolines.S.o
clang-4.0: error: unsupported option '-fPIC' for target 'i686-pc-windows-cygnus'
clang-4.0: error: unsupported option '-fPIC' for target 'i686-pc-windows-cygnus'
make[2]: *** [CMakeFiles/objc.dir/build.make:591: CMakeFiles/objc.dir/block_trampolines.S.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/objc.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
So I tried to remove -fPIC
flag from flags.cmake, but it shown a link stage error as follow
[ 27%] Linking C shared library cygobjc-4.6.dll
CMakeFiles/objc.dir/properties.m.o:(.rdata+0x1d2): multiple definition of `.objc_sel_namecopy'
CMakeFiles/objc.dir/associate.m.o:(.rdata+0xa0): first defined here
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Cannot export objc_msgSend: symbol not defined
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Cannot export objc_msgSend_fpret: symbol not found
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Cannot export objc_msgSend_stret: symbol not found
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Error: 0-bit reloc in dll
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Error: 0-bit reloc in dll
/usr/lib/gcc/i686-pc-cygwin/6.4.0/../../../../i686-pc-cygwin/bin/ld: Error: 0-bit reloc in dll
CMakeFiles/objc.dir/block_to_imp.c.o:(.text+0xaa): undefined reference to `__objc_block_trampoline_end_sret'
CMakeFiles/objc.dir/block_to_imp.c.o:(.text+0xb0): undefined reference to `__objc_block_trampoline_sret'
CMakeFiles/objc.dir/block_to_imp.c.o:(.text+0xc1): undefined reference to `__objc_block_trampoline_end'
CMakeFiles/objc.dir/block_to_imp.c.o:(.text+0xc7): undefined reference to `__objc_block_trampoline'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x72): undefined reference to `slowMsgLookup'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x84): undefined reference to `GLOBAL_OFFSET_TABLE_'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x8a): undefined reference to `SmallObjectClasses'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x10a): undefined reference to `slowMsgLookup'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x11c): undefined reference to `GLOBAL_OFFSET_TABLE_'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x122): undefined reference to `SmallObjectClasses'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x1a2): undefined reference to `slowMsgLookup'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x1b4): undefined reference to `GLOBAL_OFFSET_TABLE_'
CMakeFiles/objc.dir/objc_msgSend.S.o:(.text+0x1ba): undefined reference to `SmallObjectClasses'
CMakeFiles/objc.dir/Protocol2.m.o:(.text+0xd3): undefined reference to `_imp____objc_exec_class'
CMakeFiles/objc.dir/arc.m.o:(.text+0x372): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/arc.m.o:(.text+0x582): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/arc.m.o:(.text+0x8e1): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/arc.m.o:(.text+0x8fe): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/arc.m.o:(.text+0xb60): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/arc.m.o:(.text+0x2553): undefined reference to `_imp____objc_exec_class'
CMakeFiles/objc.dir/associate.m.o:(.text+0x2ec): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/associate.m.o:(.text+0x1023): undefined reference to `_imp____objc_exec_class'
CMakeFiles/objc.dir/properties.m.o:(.text+0x26a): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/properties.m.o:(.text+0x299): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/properties.m.o:(.text+0x3f0): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/properties.m.o:(.text+0x4e8): undefined reference to `objc_msgSend'
CMakeFiles/objc.dir/properties.m.o:(.text+0x1f33): undefined reference to `_imp____objc_exec_class'
collect2: error: ld returned 1 exit status
clang-4.0: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/objc.dir/build.make:859: cygobjc-4.6.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/objc.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
When you use method_setImplementation(Method, IMP)
or method_exchangeImplementations(Method, Method)
on a method retrieved from a metaclass and that metaclass is fully resolved, its dtable will not be updated to point to the new IMP.
Example code:
__attribute__((objc_root_class))
@interface Issue32Test
+ (void)noop; // call to force resolution
+ (int)test1;
+ (int)test2;
@end
@implementation Issue32Test
+ (void)noop { }
+ (int)test1 { return 1024; }
+ (int)test2 { return 2048; }
@end
int main(int argc, char** argv) {
[Issue32Test noop]; // <-- A
Class i32meta = object_getClass(objc_getClass("Issue32Test"));
Method m1 = class_getInstanceMethod(i32meta, @selector(test1));
Method m2 = class_getInstanceMethod(i32meta, @selector(test2));
method_exchangeImplementations(m1, m2);
assert(2048 == [Issue32Test test1]);
}
If you remove message send A, the assert passes.
This appears to be due to a bug in the design of objc_updateDtableForClassContainingMethod
. It iterates over every class (not metaclass!) known to the runtime and updates the dtable of the first class containing that method.
Moved from microsoft/WinObjC#1639.
In arc.m at line 233 the code looks to see if there is an NSAutoreleasePool class, and enables the ARC release pool if one is not found. It does this using objc_getRequiredClass, but this calls abort() if a nil is retruned, hence a nil can never be retruned to the caller.
The upshot of this is atht is not possible to use the runtime without an NSAutoreleasePool class being present, which is in contradiction to the README file, and a shame, as it would be nice to not have to implement this class.
Possibly changing intAutorelease to use objc_getClass instead of objc_getRequiredClass would fix this ?
Hi David,
I was recently bored out of my wits and wanted to test drive some wonky ideas involving object planes. Turns out that the object plane support, as advertised in the README, is a few sorts of broken right now. Here's the list of issues I have:
objc_plane_lookup()
hook is not exposed for external consumers._CLS_PLANE_AWARE
flag that has a comment about the object pointers potentially being invalid. For testing I only kept the sender == nil
test, which didn't make brimstone rain down on me, but maybe you can shed some light on the corner cases involved here. It's a bit opaque to me, but I'm speculating that it's related to GC?objc_msgSend()
is not sender-aware, and hence can't make any decisions on whether it should take the fast path (when both objects are in the same plane), or go through the slowMsgLookup mechanism, which would then delegate to the plane lookup hook.Obviously, since it's not working at all presently, it might make some sense to remove the object plane support, but I think you should be able to build some seriously cool stuff with it. I'd be willing to work on that, but I think I need some input. The objc_msgSend()
issue seems particularly tricky, since it seems to involve changing the runtime ABI.
Cheers,
Niels
Following example compiles properly, but causes an assertion at runtime:
#include <stdio.h>
#include <stdlib.h>
#include <objc/runtime.h>
#include <objc/objc-arc.h>
typedef uintptr_t NSUInteger;
__attribute__((objc_root_class))
@interface NSObject
+ (Class)class;
+ (id)alloc;
- (id)retain;
- (void)release;
- (void)dealloc;
@end
@interface NSArray : NSObject {
NSUInteger _count;
id _objects[0];
}
- (id)initWithObjects:(id *)objects count:(NSUInteger)count;
- (id)objectAtIndex:(NSUInteger)index;
@end
@interface NSPlaceholderArray : NSArray
@end
@implementation NSArray
static NSPlaceholderArray *sPlaceholder = nil;
+ (void)initialize {
if (!sPlaceholder) {
sPlaceholder = [NSPlaceholderArray alloc];
}
}
+ (id)alloc {
if (self == [NSArray class]) {
return sPlaceholder;
}
return [super alloc];
}
- (void)dealloc {
for (NSUInteger index = 0; index < _count; ++index) {
[_objects[index] release];
}
[super dealloc];
}
- (NSUInteger)count {
return _count;
}
- (id)objectAtIndex:(NSUInteger)index {
return _objects[index];
}
- (id)initWithObjects:(id *)objects count:(NSUInteger)count {
self = class_createInstance([NSArray class], sizeof(id) * count);
self->_count = count;
for (NSUInteger index = 0; index < count; ++index) {
self->_objects[index] = [objects[index] retain];
}
return self;
}
@end
@implementation NSPlaceholderArray
- (id)retain {
return self;
}
- (void)release {
}
@end
@implementation NSObject {
Class isa;
}
+ (Class)class { return self; }
+ (id)alloc {
return class_createInstance(self, 0);
}
+ (id)new
{
return [[self alloc] init];
}
- (id)init { return self; }
- (void)dealloc
{
object_dispose(self);
}
- (id)autorelease
{
return objc_autorelease(self);
}
- (id)retain
{
return objc_retain(self);
}
- (void)release
{
objc_release(self);
}
- (void)_ARCCompliantRetainRelease {}
@end
int main() {
@autoreleasepool {
id objects[3] = {[[NSObject new] autorelease], [[NSObject new] autorelease], [[NSObject new] autorelease]};
id array = [[NSArray alloc] initWithObjects:objects count:3];
printf("%tu\n%tu\n%tu\n",
(uintptr_t)(void *)[array objectAtIndex:0],
(uintptr_t)(void *)[array objectAtIndex:1],
(uintptr_t)(void *)[array objectAtIndex:2]);
[array release];
}
}
$ clang -g -fobjc-runtime=gnustep-1.8 -L/usr/local/lib/ -lobjc -Wl,-rpath=/usr/local/lib/ array.m -o array
$ ./array
array: /tmp/libobjc2/ivar.c:61: void objc_compute_ivar_offsets(Class): Assertion `ivar_size > 0' failed.
Aborted (core dumped)
But it works fine with other runtimes…
And if the size of _objects array is changed to at least 1, everything works as expected:
$ clang -g -fobjc-runtime=gnustep-1.8 -L/usr/local/lib/ -lobjc -Wl,-rpath=/usr/local/lib/ array.m -o array
$ ./array
10820552
10820616
10820648
System : debian-8.5 powerpc (32 bits), with libdispatch build from debian source (referenced as libdispatch-0~svn197 from http://libdispatch.macosforge.org/).
some test don't build with this log :
"
[ 78%] Linking C executable objc_msgSend_optimised
CMakeFiles/objc_msgSend_optimised.dir/objc_msgSend.m.o: dans la fonction « main »:
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xb54): référence indéfinie vers « objc_msgSend »
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xb90): référence indéfinie vers « objc_msgSend »
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xbac): référence indéfinie vers « objc_msgSend »
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xbbc): référence indéfinie vers « objc_msgSend »
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xbe4): référence indéfinie vers « objc_msgSend »
CMakeFiles/objc_msgSend_optimised.dir/objc_msgSend.m.o:/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xc04): encore plus de références indéfinies suivent vers « objc_msgSend »
CMakeFiles/objc_msgSend_optimised.dir/objc_msgSend.m.o: dans la fonction « main »:
/home/bertrand/Install_GNUstep/libobjc2/Test/objc_msgSend.m:(.text+0xc80): référence indéfinie vers « objc_msgSend_stret »
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Test/CMakeFiles/objc_msgSend_optimised.dir/build.make:96: recipe for target 'Test/objc_msgSend_optimised' failed
The failing test are :
Moreover, all build tests segfault with the following error in gdb :
Using host libthread_db library "/lib/powerpc-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__GI___pthread_mutex_init (mutex=0xffd7bc8, mutexattr=)
at pthread_mutex_init.c:84
84 pthread_mutex_init.c: No such file or directory.
Abd the backtrace is the following :
#0 __GI___pthread_mutex_init (mutex=0xffd7bc8, mutexattr=)
at pthread_mutex_init.c:84
#1 0x0fede398 in pthread_mutex_init (mutex=,
mutexattr=) at forward.c:188
#2 0x0ffc1638 in init_recursive_mutex ()
from /home/bertrand/Install_GNUstep/libobjc2/build/libobjc.so.4.6
#3 0x0ffc1274 in __objc_exec_class ()
from /home/bertrand/Install_GNUstep/libobjc2/build/libobjc.so.4.6
#4 0x0ffcd318 in .objc_load_function ()
from /home/bertrand/Install_GNUstep/libobjc2/build/libobjc.so.4.6
#5 0xb7fdc19c in call_init (l=, argc=argc@entry=1,
argv=argv@entry=0xbffff404, env=env@entry=0xbffff40c) at dl-init.c:78
#6 0xb7fdc304 in call_init (env=, argv=,
argc=, l=) at dl-init.c:36
#7 _dl_init (main_map=0xb7fff908, argc=1, argv=0xbffff404, env=0xbffff40c)
at dl-init.c:126
#8 0xb7fe5224 in got_label () at ../sysdeps/powerpc/powerpc32/dl-start.S:66
Backtrace stopped: frame did not save the PC
Compiling and executing the following code on FreeBSD 12.0-RELEASE-p3 (x86_64) results in a core dump:
#import <stdio.h>
#import <objc/Object.h>
__attribute__((objc_root_class))
@interface A
{
Class isa;
long double x;
}
@end
@implementation A
@end
int main(int argc, const char *argv[])
{
printf("Hello, World!\n");
return 0;
}
When I replace long double x
with double x
the above program prints „Hello, World!“.
bt in lldb shows the following:
* thread #1, name = 'hello', stop reason = signal SIGABRT
* frame #0: 0x000000080043745a
frame #1: 0x00000008003a8079
frame #2: 0x000000080026468d
frame #3: 0x0000000800263fc1
frame #4: 0x0000000800272081
frame #5: 0x0000000800271c69
frame #6: 0x00000008002661a6
frame #7: 0x00000000002013a2 hello`.objc_load_function + 18
frame #8: 0x000000080020d0fb
frame #9: 0x000000080020bf4c
I tried to build master branch with gcc 4.8.5 and gcc 5.2.0 (with help from mman-win32 project) but stuck at assembly source :
c:/msys32/gcc48/bin/../lib/gcc/i686-w64-mingw32/4.8.5/../../../../i686-w64-mingw32/bin/as.exe: BFD (tumaG86) 2.28.1 assertion fail ../../binutils-2.28.1/bfd/coff-i386.c:574
E:/Sources/libobjc2-master/objc_msgSend.x86-32.S: Assembler messages:
E:/Sources/libobjc2-master/objc_msgSend.x86-32.S:78: Error: cannot represent relocation type BFD_RELOC_386_GOTPC
c:/msys32/gcc48/bin/../lib/gcc/i686-w64-mingw32/4.8.5/../../../../i686-w64-mingw32/bin/as.exe: BFD (tumaG86) 2.28.1 assertion fail ../../binutils-2.28.1/bfd/coff-i386.c:574
E:/Sources/libobjc2-master/objc_msgSend.x86-32.S:82: Error: cannot represent relocation type BFD_RELOC_386_GOTPC
c:/msys32/gcc48/bin/../lib/gcc/i686-w64-mingw32/4.8.5/../../../../i686-w64-mingw32/bin/as.exe: BFD (tumaG86) 2.28.1 assertion fail ../../binutils-2.28.1/bfd/coff-i386.c:574
E:/Sources/libobjc2-master/objc_msgSend.x86-32.S:86: Error: cannot represent relocation type BFD_RELOC_386_GOTPC
make[2]: *** [CMakeFiles/objc.dir/build.make:577: CMakeFiles/objc.dir/objc_msgSend.S.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:61: CMakeFiles/objc.dir/all] Error 2
make: *** [Makefile:144: all] Error 2
The following error appears when building libobjc2
on Ubuntu 18.04 with Clang 6.0.0.
Scanning dependencies of target objc
[ 0%] Building C object CMakeFiles/objc.dir/abi_version.c.o
[ 1%] Building C object CMakeFiles/objc.dir/alias_table.c.o
[ 1%] Building C object CMakeFiles/objc.dir/block_to_imp.c.o
[ 2%] Building C object CMakeFiles/objc.dir/caps.c.o
[ 2%] Building C object CMakeFiles/objc.dir/category_loader.c.o
[ 3%] Building C object CMakeFiles/objc.dir/class_table.c.o
[ 4%] Building C object CMakeFiles/objc.dir/dtable.c.o
[ 4%] Building C object CMakeFiles/objc.dir/eh_personality.c.o
[ 5%] Building C object CMakeFiles/objc.dir/encoding2.c.o
[ 5%] Building C object CMakeFiles/objc.dir/hash_table.c.o
[ 6%] Building C object CMakeFiles/objc.dir/hooks.c.o
[ 6%] Building C object CMakeFiles/objc.dir/ivar.c.o
[ 7%] Building C object CMakeFiles/objc.dir/legacy_malloc.c.o
[ 7%] Building C object CMakeFiles/objc.dir/loader.c.o
[ 8%] Building C object CMakeFiles/objc.dir/mutation.m.o
[ 8%] Building C object CMakeFiles/objc.dir/protocol.c.o
[ 9%] Building C object CMakeFiles/objc.dir/runtime.c.o
[ 10%] Building C object CMakeFiles/objc.dir/sarray2.c.o
[ 10%] Building C object CMakeFiles/objc.dir/selector_table.c.o
[ 11%] Building C object CMakeFiles/objc.dir/sendmsg2.c.o
[ 11%] Building C object CMakeFiles/objc.dir/statics_loader.c.o
[ 12%] Building C object CMakeFiles/objc.dir/toydispatch.c.o
[ 12%] Building ASM object CMakeFiles/objc.dir/block_trampolines.S.o
[ 13%] Building ASM object CMakeFiles/objc.dir/objc_msgSend.S.o
[ 13%] Building C object CMakeFiles/objc.dir/NSBlocks.m.o
[ 14%] Building C object CMakeFiles/objc.dir/Protocol2.m.o
[ 15%] Building C object CMakeFiles/objc.dir/arc.m.o
[ 15%] Building C object CMakeFiles/objc.dir/associate.m.o
[ 16%] Building C object CMakeFiles/objc.dir/blocks_runtime.m.o
[ 16%] Building C object CMakeFiles/objc.dir/properties.m.o
[ 17%] Building C object CMakeFiles/objc.dir/gc_none.c.o
[ 17%] Building CXX object CMakeFiles/objc.dir/objcxx_eh.cc.o
/home/nsailor/Projects/GNUstep/libobjc2/objcxx_eh.cc:25:8: error: redefinition of 'type_info'
class type_info
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/typeinfo:88:9: note: previous definition is here
class type_info
^
1 error generated.
CMakeFiles/objc.dir/build.make:790: recipe for target 'CMakeFiles/objc.dir/objcxx_eh.cc.o' failed
make[2]: *** [CMakeFiles/objc.dir/objcxx_eh.cc.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/objc.dir/all' failed
make[1]: *** [CMakeFiles/objc.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
From what I could understand, Clang is able to emit an extendedMethodProperties
to an objc runtime protocol struct (https://github.com/llvm-mirror/clang/blob/a38ba9770a70056f9fdd6c71f819e5db45a105e4/lib/CodeGen/CGObjCMac.cpp#L2989). This property in turn is used to store a type encoding for a protocol method capable of telling us more about the method.
For instance, instead of purely @
for an object, we get its class too.
Apple's libobjc2 provides the private function
extern const char *_protocol_getMethodTypeEncoding(Protocol *p, SEL sel, BOOL isRequiredMethod, BOOL isInstanceMethod);
which gets this "special" type encoding. (an example can be found in https://gist.github.com/0xced/4969438)
How could I go about implementing support for this?
Trying to build a GNUstep environment from scratch on Ubuntu 14.04 and I'm following the script for 14.04/15.04 here. Running into an undefined error for an extern "C" global when building the tests. Output while building is below:
[ 13%] Linking C executable CXXExceptions_legacy
cd /home/mvaillant/dev/gnustep/libobjc2/build/Test && /home/mvaillant/local/bin/cmake -E cmake_link_script CMakeFiles/CXXExceptions_legacy.dir/link.txt --verbose=1
/home/mvaillant/dev/gnustep/llvm/build/bin/clang -Xclang -fexceptions -Xclang -fobjc-exceptions -rdynamic CMakeFiles/CXXExceptions_legacy.dir/CXXException.m.o CMakeFiles/CXXExceptions_legacy.dir/CXXException.cc.o CMakeFiles/test_runtime_legacy.dir/Test.m.o -o CXXExceptions_legacy -Wl,-rpath,/home/mvaillant/dev/gnustep/libobjc2/build ../libobjc.so.4.6 -lstdc++ -lm
CMakeFiles/CXXExceptions_legacy.dir/CXXException.cc.o: In function `catchall':
CXXException.cc:(.text+0x6b): undefined reference to `id_catchall'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Test/CXXExceptions_legacy] Error 1
I've noticed that the 16.04 script is significantly different, in particular it doesn't build the tests. I got through the build and install (not sure if it's working properly) avoiding the tests but it does seem that the 14.04 script is out of date (e.g. the svn for core doesn't appear to exist, I had to pull the git repos like with the 16.04 script)?
I've been working to get a large program running on Ubuntu Linux, with the clang compiler. As part of this, I took the latest source for libobjc2, gnustep-base, and gnustep-make.
After doing this, I found that the valueForKey is broken for a large class in one of my shared libraries. The class is a subclass of NSObject, so it's using the valueForKey implementation from the runtime.
I confirmed with print statements that I'm assigning the ivars correctly, but I find that the valueForKey method returns the wrong ivar for a given key. For example, I have two keys called "binary" and "argument", of type NSString* and NSArray*, respectively. I assign to these variables directly in my main program. I then attempt to print the variables in a loop, having stored their names in an array called _keys:
- (void)debugKeyLoop { NSLog(@"DBG: Printing keys"); for (NSString *key in _keys) { id v = [self valueForKey:key]; NSLog(@"DBG: debug key loop, got val %@ for key %@, my class is %@", v, key, [[self class] description]); } }
The object is called "config", and the code is:
config->binary = [NSString stringWithFormat:@"/bin/sh"];
config->argument = [[NSArray arrayWithObjects:@"-c", @"echo Child starting; sleep 10; echo Child exiting", nil] retain];
[config debugKeyLoop];
On the first iteration, the wrong value for the key "binary" is printed:
2018-01-12 17:42:53.026 MinRep[5192:5192] DBG: Printing keys
2018-01-12 17:42:53.026 MinRep[5192:5192] DBG: debug key loop, got val ("-c", "echo Child starting; sleep 10; echo Child exiting") for key binary, my class is SubprogramConfiguration
Note that the key "binary" is returning the NSArray value that was assigned to a different instance variable, "argument". The next iteration of the loop throws a segmentation fault.
My code has been around for years, and previous versions of libobjc2/gnustep-base/gnustep-make did not exhibit this problem, which leads me to suspect a problem with the libobjc2 runtime. I'm working on a minimal reproducer now. So far, the minimal code has not reproduced the bug, but I figured I would open this ticket in case owners of the runtime code might have an idea of recent changes that could cause this. If this turns out not to be reproducible or not in libobjc2, I will close this CR (I can't revert my gnustep-base and gnustep-make versions to the previous ones, because only the latest codelines are compatible).
Some time after 2018-03-28 GNUstep Base started failing during "configure" with the error message:
Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings.
This happens on both 10 and 11, no matter what compiler is used.
The following tests FAILED:
45 - objc_msgSend (SEGFAULT)
46 - objc_msgSend_optimised (SEGFAULT)
Running gdb 7.12 against these gives the following trace:
(gdb) bt
#0 0x000000080083e1d0 in objc_msgSend_fpret ()
from /home/pete/libobjc2-test/libobjc.so.4.6
#1 0x00000000004011f8 in main ()
at /home/pete/libobjc2-test/Test/objc_msgSend.m:199
I tried to get gdb to give me more info by adding -gdwarf-4 -fno-omit-frame-pointer -fno-strict-aliasing -fstack-protector to the build but it gives me the same result.
the failing test is in the registration of small object classes here:
assert(objc_registerSmallObjectClass_np(objc_getClass("Test"), 1));
a = objc_msgSend((id)01, @selector(foo));
The assert passes - i.e. the small class is added with location '1' - but the subsequent message send fails. This is in objc_msgSend.x86-64.S: and I don't do amd64 assembler in any depth unfortunately (too old, give me Vax 11 or 68k and I'm fine :-) ) so I can't debug this any further. If the issue is in the assembly language code though then it is a bit odd, as surely the optimiser (which is what is enabled in Release) would not affect that ?
Here is the output:
[ 7%] Building C object CMakeFiles/objc.dir/properties.m.o
[ 7%] Building C object CMakeFiles/objc.dir/blocks_runtime.m.o
[ 8%] Building C object CMakeFiles/objc.dir/gc_none.c.o
[ 8%] Building CXX object CMakeFiles/objc.dir/objcxx_eh.cc.o
In file included from /home/rwl4/Projects/libobjc2/objc/runtime.h:218:0,
from /home/rwl4/Projects/libobjc2/objcxx_eh.cc:6:
/home/rwl4/Projects/libobjc2/objc/slot.h:33:19: error: expected constructor, destructor, or type conversion before ‘objc_method_cache_version’
_Atomic(uint64_t) objc_method_cache_version;
^~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/objc.dir/build.make:742: recipe for target 'CMakeFiles/objc.dir/objcxx_eh.cc.o' failed
make[2]: *** [CMakeFiles/objc.dir/objcxx_eh.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/objc.dir/all' failed
make[1]: *** [CMakeFiles/objc.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Here's my clang:
$ clang -v
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8.0.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
on ppc64, compiling libobjc2 fails during linking with "ManyManySelectors.m.o: In function main': /home/cyrus/libobjc2/Test/ManyManySelectors.m:(.text+0x618): undefined reference to
objc_msgSend'"
but I also see "#warning imp_implementationWithBlock() not implemented for your architecture"
`cyrus@cyrus:~/libobjc2/Build$ make
Scanning dependencies of target objc
[ 1%] Building C object CMakeFiles/objc.dir/abi_version.c.o
[ 2%] Building C object CMakeFiles/objc.dir/alias_table.c.o
[ 3%] Building C object CMakeFiles/objc.dir/block_to_imp.c.o
/home/cyrus/libobjc2/block_to_imp.c:59:19: warning: passing 'const char *' to
parameter of type 'char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
int fd = mkstemp(pattern);
^~~~~~~
/usr/include/stdlib.h:619:27: note: passing argument to parameter '__template'
here
extern int mkstemp (char *__template) __nonnull ((1)) __wur;
^
/home/cyrus/libobjc2/block_to_imp.c:61:7: warning: passing 'const char *' to
parameter of type 'void *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
free(pattern);
^~~~~~~
/usr/include/stdlib.h:483:25: note: passing argument to parameter '__ptr' here
extern void free (void *__ptr) __THROW;
^
2 warnings generated.
[ 4%] Building C object CMakeFiles/objc.dir/caps.c.o
[ 5%] Building C object CMakeFiles/objc.dir/category_loader.c.o
[ 6%] Building C object CMakeFiles/objc.dir/class_table.c.o
[ 8%] Building C object CMakeFiles/objc.dir/dtable.c.o
[ 9%] Building C object CMakeFiles/objc.dir/eh_personality.c.o
[ 10%] Building C object CMakeFiles/objc.dir/encoding2.c.o
[ 11%] Building C object CMakeFiles/objc.dir/hash_table.c.o
[ 12%] Building C object CMakeFiles/objc.dir/hooks.c.o
[ 13%] Building C object CMakeFiles/objc.dir/ivar.c.o
[ 15%] Building C object CMakeFiles/objc.dir/legacy_malloc.c.o
[ 16%] Building C object CMakeFiles/objc.dir/loader.c.o
[ 17%] Building C object CMakeFiles/objc.dir/mutation.m.o
[ 18%] Building C object CMakeFiles/objc.dir/protocol.c.o
[ 19%] Building C object CMakeFiles/objc.dir/runtime.c.o
[ 20%] Building C object CMakeFiles/objc.dir/sarray2.c.o
[ 22%] Building C object CMakeFiles/objc.dir/selector_table.c.o
[ 23%] Building C object CMakeFiles/objc.dir/sendmsg2.c.o
[ 24%] Building C object CMakeFiles/objc.dir/statics_loader.c.o
[ 25%] Building C object CMakeFiles/objc.dir/toydispatch.c.o
[ 26%] Building ASM object CMakeFiles/objc.dir/block_trampolines.S.o
/home/cyrus/libobjc2/block_trampolines.S:106:2: warning:
imp_implementationWithBlock() not implemented for your architecture
[-W#warnings]
^
1 warning generated.
[ 27%] Building ASM object CMakeFiles/objc.dir/objc_msgSend.S.o
/home/cyrus/libobjc2/objc_msgSend.S:11:2: warning: objc_msgSend() not
implemented for your architecture [-W#warnings]
^
1 warning generated.
[ 29%] Building C object CMakeFiles/objc.dir/NSBlocks.m.o
[ 30%] Building C object CMakeFiles/objc.dir/Protocol2.m.o
[ 31%] Building C object CMakeFiles/objc.dir/arc.m.o
[ 32%] Building C object CMakeFiles/objc.dir/associate.m.o
[ 33%] Building C object CMakeFiles/objc.dir/blocks_runtime.m.o
[ 34%] Building C object CMakeFiles/objc.dir/properties.m.o
[ 36%] Building C object CMakeFiles/objc.dir/gc_none.c.o
Linking C shared library libobjc.so
[ 36%] Built target objc
Scanning dependencies of target objcxx
[ 37%] Building CXX object CMakeFiles/objcxx.dir/objcxx_eh.cc.o
Linking C shared library libobjcxx.so
[ 37%] Built target objcxx
Scanning dependencies of target AllocatePair
[ 38%] Building C object Test/CMakeFiles/AllocatePair.dir/AllocatePair.m.o
Linking C executable AllocatePair
[ 38%] Built target AllocatePair
Scanning dependencies of target AllocatePair_optimised
[ 39%] Building C object Test/CMakeFiles/AllocatePair_optimised.dir/AllocatePair.m.o
Linking C executable AllocatePair_optimised
[ 39%] Built target AllocatePair_optimised
Scanning dependencies of target AssociatedObject
[ 40%] Building C object Test/CMakeFiles/AssociatedObject.dir/AssociatedObject.m.o
Linking C executable AssociatedObject
[ 40%] Built target AssociatedObject
Scanning dependencies of target AssociatedObject2
[ 41%] Building C object Test/CMakeFiles/AssociatedObject2.dir/AssociatedObject2.m.o
Linking C executable AssociatedObject2
[ 41%] Built target AssociatedObject2
Scanning dependencies of target AssociatedObject2_optimised
[ 43%] Building C object Test/CMakeFiles/AssociatedObject2_optimised.dir/AssociatedObject2.m.o
Linking C executable AssociatedObject2_optimised
[ 43%] Built target AssociatedObject2_optimised
Scanning dependencies of target AssociatedObject_optimised
[ 44%] Building C object Test/CMakeFiles/AssociatedObject_optimised.dir/AssociatedObject.m.o
Linking C executable AssociatedObject_optimised
[ 44%] Built target AssociatedObject_optimised
Scanning dependencies of target BlockImpTest
[ 45%] Building C object Test/CMakeFiles/BlockImpTest.dir/BlockImpTest.m.o
Linking C executable BlockImpTest
[ 45%] Built target BlockImpTest
Scanning dependencies of target BlockImpTest_optimised
[ 46%] Building C object Test/CMakeFiles/BlockImpTest_optimised.dir/BlockImpTest.m.o
Linking C executable BlockImpTest_optimised
[ 46%] Built target BlockImpTest_optimised
Scanning dependencies of target BlockTest_arc
[ 47%] Building C object Test/CMakeFiles/BlockTest_arc.dir/BlockTest_arc.m.o
[ 48%] Building C object Test/CMakeFiles/BlockTest_arc.dir/Test.m.o
Linking C executable BlockTest_arc
[ 48%] Built target BlockTest_arc
Scanning dependencies of target BlockTest_arc_optimised
[ 50%] Building C object Test/CMakeFiles/BlockTest_arc_optimised.dir/BlockTest_arc.m.o
[ 51%] Building C object Test/CMakeFiles/BlockTest_arc_optimised.dir/Test.m.o
Linking C executable BlockTest_arc_optimised
[ 51%] Built target BlockTest_arc_optimised
Scanning dependencies of target BoxedForeignException
[ 52%] Building C object Test/CMakeFiles/BoxedForeignException.dir/BoxedForeignException.m.o
Linking C executable BoxedForeignException
[ 52%] Built target BoxedForeignException
Scanning dependencies of target BoxedForeignException_optimised
[ 53%] Building C object Test/CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o
Linking C executable BoxedForeignException_optimised
[ 53%] Built target BoxedForeignException_optimised
Scanning dependencies of target CXXExceptions
[ 54%] Building C object Test/CMakeFiles/CXXExceptions.dir/CXXException.m.o
[ 55%] Building CXX object Test/CMakeFiles/CXXExceptions.dir/CXXException.cc.o
Linking C executable CXXExceptions
[ 55%] Built target CXXExceptions
Scanning dependencies of target CXXExceptions_optimised
[ 56%] Building C object Test/CMakeFiles/CXXExceptions_optimised.dir/CXXException.m.o
[ 58%] Building CXX object Test/CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o
Linking C executable CXXExceptions_optimised
[ 58%] Built target CXXExceptions_optimised
Scanning dependencies of target ExceptionTest
[ 59%] Building C object Test/CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o
Linking C executable ExceptionTest
[ 59%] Built target ExceptionTest
Scanning dependencies of target ExceptionTest_optimised
[ 60%] Building C object Test/CMakeFiles/ExceptionTest_optimised.dir/ExceptionTest.m.o
Linking C executable ExceptionTest_optimised
[ 60%] Built target ExceptionTest_optimised
Scanning dependencies of target ForeignException
[ 61%] Building C object Test/CMakeFiles/ForeignException.dir/ForeignException.m.o
Linking C executable ForeignException
[ 61%] Built target ForeignException
Scanning dependencies of target ForeignException_optimised
[ 62%] Building C object Test/CMakeFiles/ForeignException_optimised.dir/ForeignException.m.o
Linking C executable ForeignException_optimised
[ 62%] Built target ForeignException_optimised
Scanning dependencies of target Forward
[ 63%] Building C object Test/CMakeFiles/Forward.dir/Forward.m.o
Linking C executable Forward
[ 63%] Built target Forward
Scanning dependencies of target Forward_optimised
[ 65%] Building C object Test/CMakeFiles/Forward_optimised.dir/Forward.m.o
Linking C executable Forward_optimised
[ 65%] Built target Forward_optimised
Scanning dependencies of target ManyManySelectors
[ 66%] Building C object Test/CMakeFiles/ManyManySelectors.dir/ManyManySelectors.m.o
/home/cyrus/libobjc2/Test/ManyManySelectors.m:40:2: warning: implicitly
declaring library function 'objc_msgSend' with type 'id (id, SEL, ...)'
objc_msgSend([Test class], nextSel);
^
/home/cyrus/libobjc2/Test/ManyManySelectors.m:40:2: note: include the header
<objc/message.h> or explicitly provide a declaration for 'objc_msgSend'
1 warning generated.
Linking C executable ManyManySelectors
CMakeFiles/ManyManySelectors.dir/ManyManySelectors.m.o: In function main': /home/cyrus/libobjc2/Test/ManyManySelectors.m:(.text+0x618): undefined reference to
objc_msgSend'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Test/CMakeFiles/ManyManySelectors.dir/build.make:86: recipe for target 'Test/ManyManySelectors' failed
make[2]: *** [Test/ManyManySelectors] Error 1
CMakeFiles/Makefile2:981: recipe for target 'Test/CMakeFiles/ManyManySelectors.dir/all' failed
make[1]: *** [Test/CMakeFiles/ManyManySelectors.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.