Сборка модулей расширения Python 3 C в Ubuntu 18.04 завершается неудачно с «перемещением R_X86_64_32 против` .rodata.str1.8 '»

Я воспроизвел на рабочем столе и на изображении Docker от 18.04.

Внутри Докера:

apt update
# perl for /usr/share/dpkg/no-pie-compile.specs as mentioned at
# https://github.com/pyca/cryptography/issues/3697
# This is the only git for apt-file as well.
apt install gcc python3-dev libdpkg-perl

Затем я пытаюсь скомпилировать мир приветствия из: https://docs.python.org/3.7/extending/embedding.html#very-high- Вложение уровня

main.c

#define PY_SSIZE_T_CLEAN
#include <Python.h>

int
main(int argc, char *argv[])
{
    wchar_t *program = Py_DecodeLocale(argv[0], NULL);
    if (program == NULL) {
        fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
        exit(1);
    }
    Py_SetProgramName(program);  /* optional but recommended */
    Py_Initialize();
    PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
    if (Py_FinalizeEx() < 0) {
        exit(120);
    }
    PyMem_RawFree(program);
    return 0;
}

с:

gcc -ggdb3 -O0 -pedantic-errors -std=c99 -Wall -Wextra $(python3-config --cflags) \
  $(python3-config --ldflags) -UNDEBUG -o 'main.out' 'main.c' \
  $(python3-config --libs)

, что не удается с:

/usr/bin/ld: /tmp/cckDInfj.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output

Сборка и запуск работ, если я разверну python3-config --cflags и удалю из него -specs=/usr/share/dpkg/no-pie-compile.specs.

Вопросы, связанные с данной:

0
задан 29 August 2019 в 15:39

0 ответов

Другие вопросы по тегам:

Похожие вопросы: