Bug 92124

Summary: shader_query.cpp:841:34: error: ‘strndup’ was not declared in this scope
Product: Mesa Reporter: Vinson Lee <vlee>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: krh, lemody, siglesias
Version: gitKeywords: bisected, regression
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Vinson Lee 2015-09-25 22:58:45 UTC
mesa: 1e97b41893a4f53a71ee141a5e8a046fed7b49cd (master 11.1.0-devel)

SCons MinGW build error

  Compiling src/mesa/main/shader_query.cpp ...
src/mesa/main/shader_query.cpp: In function ‘char* get_top_level_name(const char*)’:
src/mesa/main/shader_query.cpp:841:34: error: ‘strndup’ was not declared in this scope
    return strndup(name, name_size);
                                  ^
Comment 1 Vinson Lee 2015-09-25 23:11:19 UTC
9b477ad49d3f82503a1b8ba23dedfc05cd848fe8 is the first bad commit
commit 9b477ad49d3f82503a1b8ba23dedfc05cd848fe8
Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Date:   Wed May 6 08:11:02 2015 +0200

    main: Add SHADER_STORAGE_BLOCK and BUFFER_VARIABLE support for ARB_program_interface_query
    
    Including TOP_LEVEL_ARRAY_SIZE and TOP_LEVEL_ARRAY_STRIDE queries.
    
    v2:
    - Use std430_array_stride() to get top level array stride following std430's rules.
    
    Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
    Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
    Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>

:040000 040000 8d709c20412a7fe398eeb053c35c9c33c206e6a8 24f601f65300943b6d44fa60970899d2d8173e12 M	src
bisect run success
Comment 2 Roland Scheidegger 2015-09-26 00:59:11 UTC
Yes, that function isn't even c99. It is used in a couple more places in mesa, but afaict in no code which is compiled with windows.
Comment 3 Samuel Iglesias Gonsálvez 2015-09-28 08:13:13 UTC
Patch sent for review:

http://lists.freedesktop.org/archives/mesa-dev/2015-September/095514.html

Vinson, Would you mind testing it with SCons on MinGW?
Comment 4 Samuel Iglesias Gonsálvez 2015-09-28 11:53:53 UTC
As commented here [0], I will create a different patch to tackle this issue.

[0] http://lists.freedesktop.org/archives/mesa-dev/2015-September/095540.html
Comment 5 Samuel Iglesias Gonsálvez 2015-09-29 09:38:49 UTC
Should be fixed by:

commit bea66d22f2c0e97242c15652376ae4e82779f343
Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Date:   Mon Sep 28 14:23:34 2015 +0200

    util: implement strndup for WIN32

    v2:
    - Add strndup.h to Makefile.sources (Emil)
    - Use calloc instead of malloc (Emil).
    - Check if allocation fails (Emil, Jose)
    - Add '#pragma once' and include stdlib.h to strndup.h (Jose)

    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92124
    Reviewed-by: Jose Fonseca <jfonseca@vmware.com>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.