Skip to content

openblas_set_threads_callback_function missing prefix/suffix in shared library when SYMBOLPREFIX/SYMBOLSUFFIX are set in Makefile #5593

@lujiaweics

Description

@lujiaweics

Description

An undefined reference linking error was detected during testing. This error arises because the symbol prefix/suffix for the function openblas_set_threads_callback_function in the dynamic library is missing after SYMBOLPREFIX or SYMBOLSUFFIX is defined (this feature was introduced by PR #4577). When SYMBOLPREFIX or SYMBOLSUFFIX is configured in the Makefile, the function signature of SYMBOLPREFIX_openblas_set_threads_callback_function_SYMBOLSUFFIX in the header file cblas.h is modified (with the configured prefix/suffix added), but the function name in the dynamic link library remains unmodified, resulting in an undefined reference.

Steps to Reproduce

  1. Set SYMBOLPREFIX or SYMBOLSUFFIX in the Makefile (e.g., SYMBOLSUFFIX=_smp).
  2. Compile the OpenBLAS dynamic library.
  3. Compile and link the following test code against the compiled library:
    #include <omp.h>
    #include "cblas.h"
    
    void myfunction_(int sync, openblas_dojob_callback_smp dojob, int numjobs, size_t jobdata_elsize, void *jobdata, int dojob_data)
    {
        #pragma omp parallel for
        for(int i = 0; i < numjobs; i++)
        {
            void *element_addr = (void *) (((char *)jobdata) + ((unsigned) i) * jobdata_elsize);
            dojob(i, element_addr, dojob_data);
        }
        return;
    }
    
    int main() {
        openblas_set_num_threads_smp(4);
        omp_set_num_threads(4);
        openblas_set_threads_callback_function_smp(myfunction_);
        return 0;
    }
  4. Trigger the linking error: undefined reference to `openblas_set_threads_callback_function_smp'

Root Cause

openblas_set_threads_callback_function is not included in the exports/gensymbol and exports/gensymbol.py files. As a result, the symbol generation script does not apply the SYMBOLPREFIX/SYMBOLSUFFIX configured in the Makefile to the openblas_set_threads_callback_function when processing the dynamic library.

Related PR

The original PR that introduced the openblas_set_threads_callback_function feature: #4577

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions