Skip to content

link error when extending parquet::StreamWriter #30710

@asfimport

Description

@asfimport

When trying to extend parquet::StreamWriter so that I can support nanosecond timestamps, I ran into a strange link error.  It seems to have to do with invoking the StreamWriter::Write<>template method from the derived class.  If I comment out the invocation it links fine.

The Write<> method accesses the static constexpr  kDefLevelOne, and kRepLevelZero, which is what the linker ends up complaining about.  I'm not entirely sure, perhaps its a compiler bug.

 

Sample code to repro:

 

#include <parquet/stream_writer.h>class StreamWriter : public parquet::StreamWriter
{
public:
    StreamWriter & operator<<(int64_t v )
    { 
        CheckColumn(parquet::Type::INT64, parquet::ConvertedType::NONE);
        StreamWriter::Write<parquet::Int64Writer>( v );
        return *this;
    }
};

int main()
{
    StreamWriter writer;
    writer << int64_t( 0 );
}
 

Link Error:

 

 

binutils/binutils-2.31/bin/ld: Python-3.6.4/lib/python3.6/site-packages/pyarrow/libparquet.a(stream_writer.cc.o):(.rodata+0x78): multiple definition of `parquet::StreamWriter::kRepLevelZero'; 
binutils/binutils-2.31/bin/ld: DWARF error: can't find .debug_ranges section.
CMakeFiles/link_error.dir/link_error.cpp.o:(.rodata._ZN7parquet12StreamWriter13kRepLevelZeroE[_ZN7parquet12StreamWriter13kRepLevelZeroE]+0x0): first defined here
binutils-2.31/bin/ld: Python-3.6.4/lib/python3.6/site-packages/pyarrow/libparquet.a(stream_writer.cc.o):(.rodata+0x7a): multiple definition of `parquet::StreamWriter::kDefLevelOne'; CMakeFiles/link_error.dir/link_error.cpp.o:(.rodata._ZN7parquet12StreamWriter12kDefLevelOneE[_ZN7parquet12StreamWriter12kDefLevelOneE]+0x0): first defined here
 

 

 

Environment: Linux CentOS, compiled with gcc-11.2 and binutils-2.31
Reporter: Rob Ambalu / @robambalu

Note: This issue was originally created as ARROW-15209. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions