Skip to content

ld64.lld fails to link program with dtrace enabled #56238

@PRESIDENT810

Description

@PRESIDENT810

Hi, I was trying to link an iOS app using ReactiveObjC with ld64.lld, and it fails with saying that there is undefined symbol begins with ___dtrace. I tried to explore more using a C++ demo project, and it seems that ld64.lld does not support dtrace probed programs like ld64 does.

Here is my example:
FooProvider.d

provider Foo{
    probe added(int);
};

main.cpp

#include "FooProvider.h"

class Foo{
public:
  int test(){
    if (FOO_ADDED_ENABLED()) {
      FOO_ADDED(1);
    };
  }
};

int main() {
  Foo foo = Foo();
  int res = foo.test();
  return 0;
}

How to compile:

dtrace -h -s FooProvider.d -o FooProvider.h
clang main.cpp FooProvider.h -fuse-ld=/Users/bytedance/github/llvm-project/build/bin/ld64.lld

And ld64.lld gives the following error:

ld64.lld: error: undefined symbol: ___dtrace_probe$Foo$added$v1$696e74
>>> referenced by /var/folders/mc/j3dq2z114_l_cpcpjvnlywnr0000gp/T/main-4c3d7d.o

ld64.lld: error: undefined symbol: ___dtrace_isenabled$Foo$added$v1
>>> referenced by /var/folders/mc/j3dq2z114_l_cpcpjvnlywnr0000gp/T/main-4c3d7d.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    lld:MachOquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions