Subject: Re: [bug#68179] Re: automake-1.16j on OpenBSD

From: Bruno Haible <[email-masked]>
Date: Tue, 20 Feb 2024 12:44:44 +0100

Bogdan wrote:
>   Right. And, as I suspected, nothing in any LIBS, LD*, no libobjc found.
>   Does it work if you put
> 
> AC_LANG([Objective C])
> 
>   somewhere between the lines
> 
> 	cat >> configure.ac << 'END'
> 
> and the first
> 
> 	END
> 
> following it (i.e., in the 'configure.ac' file) in the test?

No: With this added configure.ac line (before AC_OUTPUT), the
two tests t/objcxx-minidemo.sh and t/objcxx-deps.sh still fail.

>   If not, do you know any function name that we could use in
> AC_CHECK_LIB to check for libobjc?

My test program
================================= hello.mm ==========================
#import <stdio.h>
#import <stdlib.h>
#import <iostream>

class X { int a; };

int main(void)
{
    @autoreleasepool
    {
        std::cout << @"Hello, Objective-C++.";
    }
    
    return EXIT_SUCCESS;
}
======================================================================
produces link errors w.r.t. the symbols
  objc_autoreleasePoolPush
  objc_autoreleasePoolPop
  __objc_exec_class
Is one of them suitable for testing? It depends on the ABI. Looking at
https://opensource.apple.com/source/objc4/objc4-706/runtime/objc-abi.h.auto.html
it seems better to choose one of the symbols
  _objcInit
  objc_getProperty
  objc_setProperty
  objc_setProperty_atomic
  objc_setProperty_nonatomic
  ...
  objc_copyStruct
  objc_copyCppObjectAtomic
  _objc_empty_cache
  ...

But wait! The name of the library 'libobjc' is not standardized either.

I would try to just compile a simple Objective-C++ program and see whether that
works or not. Such as:
================================ foo.mm ==============================
@interface MyClass { int _field; }
@property(nonatomic, assign) int myProperty;
@end

@implementation MyClass
@synthesize myProperty = _field;
@end

MyClass *myObject;

int main () {
  myObject.myProperty = 10;
  return 0;
}
=======================================================================
Missing symbols with clang on OpenBSD:
  objc_msg_lookup_sender
  __objc_exec_class
Missing symbols with clang on Ubuntu:
  objc_msg_lookup
  __objc_exec_class

Bruno