编译 Postgresql 禁用 "fno-aggressive-loop-optimizations"?

标签 c postgresql gcc

我正在尝试在我的系统中编译并安装 PostgreSQL。我的操作系统是 Debian 9 gcc-4.9 下面发布的是我的错误

The database cluster will be initialized with locale en_US.UTF-8. The default database encoding has accordingly been set to UTF8.

creating directory p01/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 24MB/153600
creating configuration files ... ok
creating template1 database in p01/pgsql/data/base/1 ... ok
initializing pg_authid ... FATAL:  wrong number of index expressions
STATEMENT:  CREATE TRIGGER pg_sync_pg_database   AFTER INSERT OR UPDATE OR DELETE ON   

pg_database   FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger();

child process exited with exit code 1
initdb: removing data directory "p01/pgsql/data"
<小时/>

在另一篇文章中,用户建议禁用“fno-aggressive-loop-optimizations”。但我怎样才能禁用这个功能呢?它是编译字体时./configure中的一个参数。请参阅下面的建议:

initdb: initializing pg_authid ... FATAL: wrong number of index expressions

I ran into the same problem after compiling postgresql 8.1.4 with gcc 4.9.3. The problem seems to be the way postgres uses to represent variable length arrays:

typedef struct
{
    int32       size;           /* these fields must match ArrayType! */
    int         ndim;
    int         flags;
    Oid         elemtype;
    int         dim1;
    int         lbound1;
    int2        values[1];      /* VARIABLE LENGTH ARRAY */
} int2vector;                   /* VARIABLE LENGTH STRUCT */

In some cases, for loops accessing 'values', GCC assumes that they will do one iteration at most. Loops like the one below (extracted from postgres's source code):

ii->ii_NumIndexAttrs = numKeys;
for (i = 0; i < numKeys; i++)
    ii->ii_KeyAttrNumbers[i] = indexStruct->indkey.values[i];

might end up being reduced to something like:

ii->ii_NumIndexAttrs = numKeys;
if (numKeys)
    ii->ii_KeyAttrNumbers[0] = indexStruct->indkey.values[0];

as deduced by looking at the assembler generated for it:

.L161:
    testl   %r12d, %r12d
    movl    %r12d, 4(%rbx)
    jle .L162
    movzwl  40(%r13), %eax
    movw    %ax, 8(%rbx)
.L162:

The problem went away after re-compiling postgres with that optimization disabled by using -fno-aggressive-loop-optimizations.

最佳答案

感谢您的提示...我能够解决问题。

如果有人遇到此问题,这里是解决方案。

为了使用 GCC-4.9 编译 PostgreSQL 9.0.1 源代码,我在 postgresql 源代码中使用了以下指令:

./configure -prefix=/opt/postgres9.0 CFLAGS="-Wno-aggressive-loop-optimizations"

Wno-aggressive-loop-optiimizations 禁用激进的 GCC 优化,避免上一条消息和讨论中报告的错误-List pgsql-general -> https://www.postgresql.org/message-id/CAOD%3DoQ-kq3Eg5SOvRYOVxDuqibVWC8R0wEivPsMGcyzZY-nfzA%40mail.gmail.com

我希望删除“GCC 激进循环优化”不会导致 DBMS 中出现任何类型的错误。

关于编译 Postgresql 禁用 "fno-aggressive-loop-optimizations"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41412118/

相关文章:

c - libdtrace 缓冲输出

c - 使用 gdb 进入带有共享库的第 3 方函数

linux - 在 Linux 中是否有一种异步安全的方法来获取当前线程 ID?

c - GCC Win32 API 与 ComCtl32 的链接问题

c - 从递归到迭代(循环)

c++ - Linux、waitpid、WNOHANG 和僵尸

python - 填充枚举数组

postgresql - Postgres : Concat multiple columns, 同时包含空值

postgresql - 如何将 to_tsvector 与无字典(无词干)一起使用?

c - __asm__ __volatile__ 在 C 中做什么?