github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/godefs.cc (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  #include "godefs.h"
    12  #include <stdio.h>
    13  #include <stdlib.h>
    14  
    15  extern "C" {
    16  static void __attribute__((noreturn)) die_missing_symbol(const char* name) {
    17    fprintf(stderr, "%s symbol missing; expected to be supplied by Go\n", name);
    18    abort();
    19  }
    20  
    21  // These are Go functions exported by storage/engine. We provide these stubs,
    22  // which simply panic if called, to to allow intermediate build products to link
    23  // successfully. Otherwise, when building ccl/storageccl/engineccl, Go will
    24  // complain that these symbols are undefined. Because these stubs are marked
    25  // "weak", they will be replaced by their proper implementation in
    26  // storage/engine when the final cockroach binary is linked.
    27  void __attribute__((weak)) rocksDBLog(bool, int, char*, int) { die_missing_symbol(__func__); }
    28  char* __attribute__((weak)) prettyPrintKey(DBKey) { die_missing_symbol(__func__); }
    29  }  // extern "C"