Error while trying to export_library when obj file is too large

I am trying to compile and export lib from huggingface gpt2 model, but the generated obj file it too large(>= 2GB) so that the export_lib failed as below

RuntimeError: Compilation error:
/lib/../lib64/crti.o: In function `_init':
(.init+0x7): relocation truncated to fit: R_X86_64_GOTPCREL against undefined symbol `__gmon_start__'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtbeginS.o: In function `deregister_tm_clones':
crtstuff.c:(.text+0x3): relocation truncated to fit: R_X86_64_PC32 against `.tm_clone_table'
crtstuff.c:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `__TMC_END__' defined in .got.plt section in gpt2_batchsize_32_dtype_float16.so
crtstuff.c:(.text+0x1a): relocation truncated to fit: R_X86_64_REX_GOTPCRELX against undefined symbol `_ITM_deregisterTMCloneTable'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtbeginS.o: In function `register_tm_clones':
crtstuff.c:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against `.tm_clone_table'
crtstuff.c:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `__TMC_END__' defined in .got.plt section in gpt2_batchsize_32_dtype_float16.so
crtstuff.c:(.text+0x6b): relocation truncated to fit: R_X86_64_REX_GOTPCRELX against undefined symbol `_ITM_registerTMCloneTable'
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtbeginS.o: In function `__do_global_dtors_aux':
crtstuff.c:(.text+0x92): relocation truncated to fit: R_X86_64_PC32 against `.bss'
crtstuff.c:(.text+0x9c): relocation truncated to fit: R_X86_64_GOTPCREL against symbol `__cxa_finalize@@GLIBC_2.2.5' defined in .text section in /lib64/libc.so.6
crtstuff.c:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `__dso_handle' defined in .data.rel.ro.local section in /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/crtbeginS.o
crtstuff.c:(.text+0xba): additional relocation overflows omitted from the output
gpt2_batchsize_32_dtype_float16.so: PC-relative offset overflow in GOT PLT entry for `__gmon_start__'
collect2: error: ld returned 1 exit status

I found the same issue in 26386 – libc_nonshared.a 32-bit relocations. It seems I should re-compile my toolchain to solve this problem, right?

BTW, I try to use float16 mode and expect that the size of obj file will be smaller. But the size increase from 2.1GB(float32) to 3.7GB(float16).