firasuke / cross / slibtool

Forked from cross/slibtool 6 months ago
Clone

56f2d4 driver: slbt_init_host_params(): propagate failure of <compiler> -dumpmachine.

Authored and Committed by midipix 6 years ago
    driver: slbt_init_host_params(): propagate failure of <compiler> -dumpmachine.
    
        
file modified
+21 -7
src/driver/slbt_driver_ctx.c CHANGED
@@ -416,6 +416,7 @@ static void slbt_get_host_quad(
416
416
}
417
417
418
418
static int slbt_init_host_params(
419
+ const struct slbt_driver_ctx * dctx,
419
420
const struct slbt_common_ctx * cctx,
420
421
struct slbt_host_strs * drvhost,
421
422
struct slbt_host_params * host,
@@ -458,10 +459,12 @@ static int slbt_init_host_params(
458
459
if (host->host) {
459
460
cfgmeta->host = cfgexplicit;
460
461
fhost = true;
462
+
461
463
} else if (cctx->target) {
462
464
host->host = cctx->target;
463
465
cfgmeta->host = cfgtarget;
464
466
ftarget = true;
467
+
465
468
} else if (strrchr(base,'-')) {
466
469
if (!(drvhost->host = strdup(cctx->cargv[0])))
467
470
return -1;
@@ -471,9 +474,22 @@ static int slbt_init_host_params(
471
474
host->host = drvhost->host;
472
475
cfgmeta->host = cfgcompiler;
473
476
fcompiler = true;
474
- } else if (fdumpmachine && !(slbt_dump_machine(
475
- cctx->cargv[0],
476
- buf,sizeof(buf)))) {
477
+
478
+ } else if (!fdumpmachine) {
479
+ host->host = drvhost->machine;
480
+ cfgmeta->host = cfgnmachine;
481
+ fnative = true;
482
+
483
+ } else if (slbt_dump_machine(cctx->cargv[0],buf,sizeof(buf)) < 0) {
484
+ if (dctx)
485
+ slbt_dprintf(
486
+ slbt_driver_fderr(dctx),
487
+ "%s: could not determine host "
488
+ "via -dumpmachine\n",
489
+ dctx->program);
490
+ return -1;
491
+
492
+ } else {
477
493
if (!(drvhost->host = strdup(buf)))
478
494
return -1;
479
495
@@ -494,10 +510,6 @@ static int slbt_init_host_params(
494
510
&& !strcmp(hostquad[1],machinequad[1])
495
511
&& !strcmp(hostquad[2],machinequad[2]);
496
512
}
497
- } else {
498
- host->host = drvhost->machine;
499
- cfgmeta->host = cfgnmachine;
500
- fnative = true;
501
513
}
502
514
503
515
/* flavor */
@@ -1233,6 +1245,7 @@ int slbt_get_driver_ctx(
1233
1245
1234
1246
} else {
1235
1247
if (slbt_init_host_params(
1248
+ &ctx->ctx,
1236
1249
&ctx->cctx,
1237
1250
&ctx->host,
1238
1251
&ctx->cctx.host,
@@ -1366,6 +1379,7 @@ int slbt_set_alternate_host(
1366
1379
ictx->ctx.cctx.ahost.flavor = ictx->ctx.ahost.flavor;
1367
1380
1368
1381
if (slbt_init_host_params(
1382
+ 0,
1369
1383
ctx->cctx,
1370
1384
&ictx->ctx.ahost,
1371
1385
&ictx->ctx.cctx.ahost,