Skip to content

get wrong result when compile c to wasm with -ffreestanding flag #78

Closed
@elvin-du

Description

@elvin-du

compile pow function that musl standard c library to wasm using clang, when with -ffreestanding flag, will get wrong result. for example:

#include <math.h>
void printdf(double a):
void test(){
         printdf(pow((double)2.0, (double)0.3));
}

use following command to compile:

clang  --target=wasm32 -ffreestanding ............... -o test.wasm

the function print 1,not 1.2311444133449163.

I test using all following version of clang, the results are the same, all are 1.

version:

v4.0, v7.0, v9.0

but, if I do not with -ffreestanding flag, all the result are 1.2311444133449163.

test environment:

OS:

apple, and centos

arch:

x86-64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions