Skip to content

fix: Fix compiler error in debug build - #1368

Merged
krlmlr merged 1 commit into
duckdb:mainfrom
joakimlinde:misc/compile-error-in-debug
Jul 25, 2025
Merged

krlmlr merged 1 commit into
duckdb:mainfrom
joakimlinde:misc/compile-error-in-debug

Conversation

@joakimlinde

Copy link
Copy Markdown
Contributor

This is to fix a compiler error in debug build. Here is the offending line (line 178):

D_ASSERT(dest_offset == nrows);

The variable rows is renamed to nrows to make it consistent with ncols.

This is to fix a compiler error in debug build. Here is the offending line (line 178):

D_ASSERT(dest_offset == nrows);

The variable rows is renamed to nrows to make it consistent with ncols.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.62%. Comparing base (5c88c6f) to head (0f9d5aa).
Report is 2124 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1368       +/-   ##
===========================================
- Coverage   63.61%   52.62%   -11.00%     
===========================================
  Files         123      146       +23     
  Lines        5266    10017     +4751     
===========================================
+ Hits         3350     5271     +1921     
- Misses       1916     4746     +2830     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@krlmlr krlmlr changed the title FIx compiler error in debug build fix: FIx compiler error in debug build Jul 25, 2025
@krlmlr krlmlr changed the title fix: FIx compiler error in debug build fix: Fix compiler error in debug build Jul 25, 2025
@krlmlr

krlmlr commented Jul 25, 2025

Copy link
Copy Markdown
Collaborator

Thanks. How do you enable the debug build?

@krlmlr
krlmlr enabled auto-merge July 25, 2025 09:37
@krlmlr
krlmlr disabled auto-merge July 25, 2025 09:37
@krlmlr
krlmlr enabled auto-merge (squash) July 25, 2025 09:37
@krlmlr
krlmlr merged commit 924a8e9 into duckdb:main Jul 25, 2025
@joakimlinde

joakimlinde commented Jul 26, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks. How do you enable the debug build?

In RStudio in the Build tab I select More... -> Load All. In the console I get the following output (note the "(debug build)"):

> devtools::load_all(".")
ℹ Loading duckdb
ℹ Re-compiling duckdb (debug build)
── R CMD INSTALL

...

clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -Iinclude 
-I../inst/include -DDUCKDB_DISABLE_PRINT -DDUCKDB_R_BUILD -DBROTLI_ENCODER_CLEANUP_ON_OOM 
-DDUCKDB_EXTENSION_AUTOLOAD_DEFAULT -DDUCKDB_RSTRTMGR=1 -Iduckdb/src/include 
-Iduckdb/third_party/concurrentqueue -Iduckdb/third_party/fast_float -Iduckdb/third_party/fastpforlib 
-Iduckdb/third_party/fmt/include -Iduckdb/third_party/fsst -Iduckdb/third_party/httplib -Iduckdb/third_party/hyperloglog 
-Iduckdb/third_party/jaro_winkler -Iduckdb/third_party/jaro_winkler/details -Iduckdb/third_party/libpg_query 
-Iduckdb/third_party/libpg_query/include -Iduckdb/third_party/lz4 -Iduckdb/third_party/brotli/include 
-Iduckdb/third_party/brotli/common -Iduckdb/third_party/brotli/dec -Iduckdb/third_party/brotli/enc 
-Iduckdb/third_party/mbedtls/include -Iduckdb/third_party/mbedtls/library -Iduckdb/third_party/miniz 
-Iduckdb/third_party/pcg -Iduckdb/third_party/re2 -Iduckdb/third_party/skiplist -Iduckdb/third_party/tdigest 
-Iduckdb/third_party/utf8proc -Iduckdb/third_party/utf8proc/include -Iduckdb/third_party/yyjson/include 
-Iduckdb/third_party/zstd/include -Iduckdb/extension/parquet/include -Iduckdb/third_party/parquet 
-Iduckdb/third_party/thrift -Iduckdb/third_party/lz4 -Iduckdb/third_party/brotli/include 
-Iduckdb/third_party/brotli/common -Iduckdb/third_party/brotli/dec -Iduckdb/third_party/brotli/enc 
-Iduckdb/third_party/snappy -Iduckdb/third_party/mbedtls -Iduckdb/third_party/mbedtls/include 
-Iduckdb/third_party/zstd/include -Iduckdb/extension/core_functions/include -I../inst/include -Iduckdb 
-DDUCKDB_EXTENSION_PARQUET_LINKED -DDUCKDB_BUILD_LIBRARY 
-DDUCKDB_EXTENSION_CORE_FUNCTIONS_LINKED -DDUCKDB_BUILD_LIBRARY  -I/opt/R/arm64/include 
-fPIC  -falign-functions=64 -Wall -g -O2  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always  
-c statement.cpp -o statement.o

Here you can see -DNDEBUG at the very beginning and then -UNDEBUG at the very end. I would assume that the compiler interprets is as if we first define NDEBUG and then change our mind and undefined it. There are similar odd things going on because we first -g -O2 (which is really odd - debug symbols with optimization level 2) then later we change our mind and do -g -O0 (which makes more sense).

@krlmlr

krlmlr commented Jul 26, 2025

Copy link
Copy Markdown
Collaborator

Thanks. The -UNDEBUG looks nonstandard. Do you have a file ~/.R/Makevars or a specific build configuration for R?

@joakimlinde

Copy link
Copy Markdown
Contributor Author

Do you have a file ~/.R/Makevars or a specific build configuration for R?

No ~/.R/Makevars, not even a ~/.R dir. I believe what you are looking for is line 56 in compile-dll.R in package pkgbuild.

  debug = TRUE

Here are my compiler flags:

> pkgbuild::compiler_flags()
                                      CFLAGS                                     CXXFLAGS 
"-Wall -pedantic -fdiagnostics-color=always" "-Wall -pedantic -fdiagnostics-color=always" 
                                  CXX11FLAGS                                   CXX14FLAGS 
"-Wall -pedantic -fdiagnostics-color=always" "-Wall -pedantic -fdiagnostics-color=always" 
                                  CXX17FLAGS                                   CXX20FLAGS 
"-Wall -pedantic -fdiagnostics-color=always" "-Wall -pedantic -fdiagnostics-color=always" 
> pkgbuild::compiler_flags(debug = TRUE)
                                                      CFLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                    CXXFLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                  CXX11FLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                  CXX14FLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                  CXX17FLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                  CXX20FLAGS 
"-UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always" 
                                                      FFLAGS 
                                                    "-g -O0" 
                                                     FCFLAGS 
                                                    "-g -O0" 

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants